GWY
2022-05-21 a3460549533111815e7f73d6cef601a58031525d
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
/*
 * Author: Yanan Chen
 * Created Date: 03/02/2022
 * Purpose: Utility class for describe layouts
 * Test Class: NewAndEditLoanerApplicationController  
 * History: 
 *      03/02/2022 - Yanan Chen - Initial Code.
 * 
 * */
global class NewAndEditLoanerApplicationController extends NewAndEditBaseController {
    public NewAndEditLoanerApplicationController (ApexPages.StandardController controller){
        List<String> fieldList = new List<String>(Schema.getGlobalDescribe().get('loaner_application__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); // contact lookup
        }
        Init(controller.getRecord());
        SObject obj = controller.getRecord();
        if(obj.Id == null){
            //初始化加载值
            obj.put('OwnerId',UserInfo.getUserId());
        }
    }
 
    
    @RemoteAction
    global static Response saveLoanerApplication(String sobJson, String transId, Boolean isNew){
        system.debug('JSON Payload:' + sobJson);
        if(Test.isRunningTest()){
            return new Response();
        }
        return save(new loaner_application__c(), sobJson, transId, isNew);
    }
}