| | |
| | | Map<String, Schema.SObjectField> fieldAPIToTypeMap = leadSchema.getDescribe().fields.getMap(); |
| | | Map<String,Object> fieldValueMap = (Map<String,Object>)JSON.deserializeUntyped(leadJson); |
| | | |
| | | system.debug('enter Foo'); |
| | | string rtid = null; |
| | | if (fieldValueMap.containsKey('RecordTypeId')) { |
| | | rtid = String.valueOf(fieldValueMap.get('RecordTypeId')); |
| | | } |
| | | List<string> invalid_fields = GetInvalidFieldFromLayout(rtid,sobjectTypeValue); |
| | | |
| | | Boolean isClone = false; |
| | | //2. Save Record Process |
| | |
| | | |
| | | for (String fieldAPI: fieldValueMap.keySet()) { |
| | | system.debug('field API='+fieldAPI); |
| | | |
| | | if(invalid_fields.contains(fieldAPI)){ |
| | | system.debug(fieldAPI+' is invalid'); |
| | | continue; |
| | | } |
| | | |
| | | if(!fieldAPIToTypeMap.containskey(fieldAPI)){ |
| | | continue; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | public static List<string> GetInvalidFieldFromLayout(string rtid, string sobject_name){ |
| | | List<string> ls = new List<string>(); |
| | | string[] only_type = new string[]{'QIS_Report__c'}; |
| | | if(!only_type.contains(sobject_name)){ |
| | | system.debug('not allow'); |
| | | return ls; |
| | | } |
| | | |
| | | List<Metadata.LayoutSection> sections = MetaDataUtility.GetRecordTypePageLayout(rtid, sobject_name); |
| | | |
| | | if (sections == null) { |
| | | System.debug('sections=null'); |
| | | return ls; |
| | | } |
| | | |
| | | system.debug(Json.serialize(sections)); |
| | | |
| | | for (Metadata.LayoutSection section : sections) { |
| | | if (section.layoutColumns != null) { |
| | | for (Metadata.LayoutColumn layoutColumn : section.layoutColumns) { |
| | | if(layoutColumn.layoutItems != null){ |
| | | for (Metadata.LayoutItem item : layoutColumn.layoutItems) { |
| | | |
| | | System.debug(item); |
| | | if(item.field==null)continue; |
| | | if (item.behavior == Metadata.UiBehavior.READONLY ) { |
| | | ls.add(item.field); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | return ls; |
| | | } |
| | | } |