Fixing Template Errors After Template Migration
Problem
You or a client just used the standard migration method under S-Docs Setup to migrate templates from one org to another. Afterwards, most or all of those templates trigger an error upon use until you go to that template and manually re-save it.
Solution
1
2
Step: Add Apex class to toggle the field
Add the following Apex class to auto-toggle that field from TRUE to FALSE:
public class HasErrorToggler {
public static void toggleBooleanField(List<SObject> records, String fieldName) {
if (records == null || records.isEmpty()) return;
for (SObject rec : records) {
Boolean currentValue = (Boolean) rec.get(fieldName);
rec.put(fieldName, currentValue == null ? true : !currentValue);
}
update records;
}
}3
Last updated
Was this helpful?

