Build 3.56 (04tRl000001D4hxIAC)
From all versions below 3.50.6
List<delpha__DDQ_DuplicateObject__c> dupObjs = [SELECT Id, Name, delpha__Expression__c FROM delpha__DDQ_DuplicateObject__c];
for(delpha__DDQ_DuplicateObject__c dupObj : dupObjs) {
String expRuleStr = dupObj.delpha__Expression__c;
System.debug('Current Rule: ' + expRuleStr);
if(String.isBlank(expRuleStr) || !(expRuleStr.startsWith('[[') && expRuleStr.endsWith(']]'))) { //check here if expRule is in old format (field is not filterable in query)
continue; //skip if already in new format
}
List<Object> expRuleList = (List<Object>) JSON.deserializeUntyped(expRuleStr);
List<Map<String, Object>> newExpRules = new List<Map<String, Object>>();
Integer i = 1;
for(Object rule : expRuleList) {
Map<String,Object> newRule = new Map<String, Object> {
'name' => 'Rule ' + i,
'rules' => rule
};
newExpRules.add(newRule);
i++;
}
System.debug('New Rule: ' + JSON.serialize(newExpRules));
dupObj.delpha__Expression__c = JSON.serialize(newExpRules);
}
Database.update(dupObjs);Last updated
Was this helpful?