global class NewAndEditInquiryFormController extends NewAndEditBaseController 
{
    // public String contactsInfo {set;get;}//key sfid;value awsid
    // public String leadsInfo {set;get;}//key sfid;value awsid
    public String PIPL_Input_Account_Error_Msg{set;get;}
    public String contactId{set;get;}//For Lookup field
    public String leadId{set;get;}//For Lead Lookup
    public String staticResourceContact {get; set;}
    public String staticResourceLead {get; set;}
    public String urlCheckContactAWSid {get; set;}
    public NewAndEditInquiryFormController(ApexPages.StandardController controller) {
        List<String> fieldList = new List<String>(Schema.getGlobalDescribe().get('Inquiry_form__c').getDescribe().fields.getMap().keyset());  
        // Add fields to controller. This is to avoid the SOQL error in visualforce page
        controller.addFields(fieldList);
        // contact lookup
        LookUpOverrideFields.add('Contact_Name__c');
        LookUpOverrideFields.add('Lead_link__c');
        Init(controller.getRecord());
        //添加项
        PIPL_Input_Account_Error_Msg = label.PIPL_Input_Account_Error_Msg;
        SObject obj = controller.getRecord();
        if(obj.Id == null){
            //初始化加载值
            obj.put('OwnerId',UserInfo.getUserId());
        }
        //contact信息（搜索查询query url用）
        staticResourceContact = JSON.serialize(PIHelper.getPIIntegrationInfo('Contact'));
        //Lead信息（搜索查询query url用）
        staticResourceLead = JSON.serialize(PIHelper.getPIIntegrationInfo('Lead'));

        checkUrl('CF00N1000000962n8_lkid','Contact');
    }

    @RemoteAction
    global static Response saveInquiryForm(String leadJson,String transId,Boolean isNew) {
        return save(new Inquiry_form__c(),leadJson,transId,isNew);
    }

    private void checkUrl(String urlStr, String sobjType){
        Map<String, String> urlFieldMap = new Map<String, String>();
        urlFieldMap = ApexPages.currentPage().getParameters();
        if (urlFieldMap.containsKey(urlStr)) {
            String sobjId = urlFieldMap.get(urlStr);
            String soql = 'select id,AWS_Data_Id__c from ' + sobjType;
            soql += ' where id=\'' + sobjId + '\'';
            Sobject sobj = Database.query(soql);

            Map<String, String> m = new Map<String, String>();
            m.put((String)sobjId, (String)sobj.get('AWS_Data_Id__c'));

            LookUpOverrideFieldsMapJson = JSON.serialize(m);
        }
    }
}