liuyn
2024-03-11 a87f1c3df03078814ee97ad0c8ac200a232419e9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
 * Created Date: 07/04/2022
 * Purpose: Utility class for describe layouts
 * Test Class: NewAndEditAgencyOpportunityController
 * History: 
 *      07/04/2022 - Yanan Chen - Initial Code.
 * 
 * */
global class NewAndEditAgencyOpportunityController  extends NewAndEditBaseController{
    public String agencyContactAWSId{set;get;}
    public String staticAgencyContactResources {get; set;}
    public NewAndEditAgencyOpportunityController (ApexPages.StandardController controller) {
        
        List<String> fieldList = new List<String>(Schema.getGlobalDescribe().get('Agency_Opportunity__c').getDescribe().fields.getMap().keyset());  
        // Add fields to controller. This is to avoid the SOQL error in visualforce page
        if (!Test.isRunningTest()) { 
            controller.addFields(fieldList);
        }
        // Init(controller.getRecord());
        
        SObject obj = controller.getRecord();  
        //1. get 访问对象ID
        //query event by controller.getRecord().Id;
        if(obj.Id != null){
            Agency_Opportunity__c ao = [SELECT  Id, Agency_Contact__c FROM Agency_Opportunity__c WHERE Id =:obj.Id];
            System.debug('ao: ' + ao);
            if(ao != null){
                List<Agency_Contact__c> ac = [select AWS_Data_Id__c,Name from Agency_Contact__c where id=:ao.Agency_Contact__c];
                    if(ac.size()>0){
                        if (ac[0].AWS_Data_Id__c != null && ac[0].AWS_Data_Id__c != '') {
                            agencyContactAWSId = ac[0].AWS_Data_Id__c;
                        }
                    }
            } else {
                agencyContactAWSId = '无';
            }
        }
        staticAgencyContactResources = JSON.serialize(PIHelper.getPIIntegrationInfo('Agency_Contact__c'));
    }
}