From 8badb57ea2c82557850ad5b39281c3e8714eb119 Mon Sep 17 00:00:00 2001
From: liuyan <liuyan@prec-tech.com>
Date: 星期四, 24 十一月 2022 10:08:31 +0800
Subject: [PATCH] 科室信息漏传SPO问题
---
force-app/main/default/classes/NewAndEditBaseController.cls | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 51 insertions(+), 2 deletions(-)
diff --git a/force-app/main/default/classes/NewAndEditBaseController.cls b/force-app/main/default/classes/NewAndEditBaseController.cls
index 6474e93..462ae89 100644
--- a/force-app/main/default/classes/NewAndEditBaseController.cls
+++ b/force-app/main/default/classes/NewAndEditBaseController.cls
@@ -198,7 +198,13 @@
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
String status = 'success';
@@ -210,6 +216,12 @@
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;
}
@@ -252,7 +264,7 @@
isClone = sobjects.size() == 0;
}
System.debug('isNew---------'+isNew);
-
+
if(isNew || isClone){
System.debug('leadInfozhj = ' + leadInfo);
if(!Test.isRunningTest()){
@@ -312,4 +324,41 @@
}
}
+ 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;
+ }
}
\ No newline at end of file
--
Gitblit v1.9.1