This step is important if you have existing set targets so that TaroWorks Mobile Users can see their targets on their mobile devices once they upgrade to TaroWorks 7.4.
- Go to Set up>Object Manager and select Assigned Target Object.
- Click Validation Rules and select "Disable_Editing_Fields" validation rule.
- Edit and deactivate the rule.
Note: Failure to deactivate the rule before running the script below will result to an error when you attempt to run the script. - Click Save.
- Go to Setup > Developer Console.
- Click Debug > Open Execute Anonymous Window.
- Copy and Paste the following:
List<gfsurveys__AssignedTarget__c> existingTargets = [Select Id, gfsurveys__Contact__c, gfsurveys__User__c From gfsurveys__AssignedTarget__c Where gfsurveys__Status__c =
'Active'
];
Map<Id, Id> contactVsTMUId =
new
Map<Id, Id>();
Set<Id> contactIds =
new
Set<Id>();
List<gfsurveys__AssignedTarget__c> targetsToUpdate =
new
List<gfsurveys__AssignedTarget__c>();
for
(gfsurveys__AssignedTarget__c at : existingTargets){
contactIds.add(at.gfsurveys__Contact__c);
}
for
(gfsurveys__Taroworks_Mobile_User__c tmu : [Select Id, gfsurveys__User__c, gfsurveys__Contact__c From gfsurveys__Taroworks_Mobile_User__c Where gfsurveys__Contact__c In :contactIds]){
contactVsTMUId.put(tmu.gfsurveys__Contact__c, tmu.Id);
}
for
(gfsurveys__AssignedTarget__c at : existingTargets){
if
(contactVsTMUId.containsKey(at.gfsurveys__Contact__c)){
gfsurveys__AssignedTarget__c target = at;
target.gfsurveys__User__c = contactVsTMUId.get(at.gfsurveys__Contact__c);
targetsToUpdate.add(target);
}
}
if
(targetsToUpdate.size() >
0
){
update targetsToUpdate;
}
8. Click Execute.
9. Repeat steps 1-3 to activate the validation rule.
10. Click Save.
Conclusion
Congratulations you've updated the existing set targets. Please continue to 05. Update Existing Forms to check the Run Hidden Dynamic Operations Checkbox
Comments
0 comments
Please sign in to leave a comment.