| | |
| | | if (String.isBlank(recordTypeId)) { |
| | | data.put('recordTypeId', LayoutDescriberHelper.getDefaultRecordType(sobjectType)); |
| | | } |
| | | |
| | | |
| | | //编辑 |
| | | if(!String.isBlank(rid)){ |
| | | if (!String.isBlank(rid)) { |
| | | //获取对应对象的字段 List<Sobject> lso = Database.query('select id from RecordType where SobjectType = :sobjectType'); |
| | | String sql = 'select '; |
| | | 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'; |
| | | sql += String.join(objectFields, ',') + ' from ' + sobjectType + ' where id =\'' + rid + '\' limit 1'; |
| | | System.debug('sql = ' + sql); |
| | | Sobject leadData = Database.query(sql); |
| | | if(leadData == null){ |
| | | return new ResponseBodyLWC('Error',500, 'id不存在', ''); |
| | | if (leadData == null) { |
| | | return new ResponseBodyLWC('Error', 500, 'id不存在', ''); |
| | | } |
| | | if(objectFields.contains('recordtypeid')){ |
| | | recordTypeId = (String)leadData.get('RecordTypeId'); |
| | | if (objectFields.contains('recordtypeid')) { |
| | | recordTypeId = (String) leadData.get('RecordTypeId'); |
| | | System.debug('recordTypeId: ' + recordTypeId); |
| | | } |
| | | List<Metadata.LayoutSection> layout = MetaDataUtility.GetRecordTypePageLayout(recordTypeId, sobjectType); |
| | | data.put('layout', Json.serialize(reviseMetaLayouts(layout))); |
| | | data.put('recordTypeId', recordTypeId); |
| | | System.debug('data.recordTypeId: ' + data.get('recordTypeId')); |
| | | data.put('AWSDataId', (String)leadData.get('AWS_Data_Id__c')); |
| | | data.put('AWSDataId', (String) leadData.get('AWS_Data_Id__c')); |
| | | //获取值 |
| | | System.debug('leadData = ' + JSON.serialize(leadData)); |
| | | data.put('data', leadData); |
| | | }else { |
| | | } else { |
| | | List<Metadata.LayoutSection> layout = MetaDataUtility.GetRecordTypePageLayout(recordTypeId, sobjectType); |
| | | data.put('layout', Json.serialize(reviseMetaLayouts(layout))); |
| | | } |
| | |
| | | private static Boolean isUpdateable(Schema.DescribeFieldResult dfr) { |
| | | return (new List<String>{ 'Id', 'Name' }).contains(dfr.getName()) || dfr.isUpdateable(); |
| | | } |
| | | } |
| | | } |