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
/*
 * Author: Zhang,Heyang
 * Created Date: 08/07/2023
 * Purpose: get page layout and record data
 * Test Class: LexNewAndEditRepairOrderPIPLTest
 * */
public with sharing class LexNewAndEditRepairOrderPIPLController {
    @AuraEnabled
    public static ResponseBodyLWC initData(Id rid, String recordTypeId, String sobjectType) {
        Map<String, object> data = new Map<String, object>();
        ResponseBodyLWC rbl = LexNewAndEditBasePIPLController.initData(rid, recordTypeId, sobjectType);
        if(rbl.status == 'Success'){
            data = (Map<String,Object>)rbl.entity;
            data.put('staticResourceContact', Json.serialize(PIHelper.getPIIntegrationInfo('Contact')));
            if(String.isNotBlank(rid)){
                String sql = 'SELECT Applicanter__r.lastName,Applicanter__r.AWS_Data_Id__c,Receiver__r.lastName,Receiver__r.AWS_Data_Id__c, ';
                DescribeSObjectResult objectType = rid.getSobjectType().getDescribe();
                List<String> objectFields = new List<String>(objectType.fields.getMap().keySet());
                sql += String.join(objectFields, ',') +' from '+sobjectType+' where id =\''+rid+'\' limit 1';
                System.debug('sql: ' + sql);
                Sobject leadData = Database.query(sql);
                data.put('data',leadData);
            }
 
            rbl.entity = data;
        }
        return rbl;
    }
}