I want to do something similar with what this forum is asking, but with more of a list of objects and not a shared field.
I have an object called Call_Report__c
and upon save, I want to get its field value called Apps_to_Relate__c
which has a string of recordId's of the object Application__c
separated by a comma.
I want to update a field of Application__c
objects in that string field Apps_to_Relate__c
to be the recordId of Apps_to_Relate__c
.
How can I go about this? This is the code I have so far:
trigger CallReportTrigger on Call_Report__c (after insert, after update) {
Map<String, Call_Report__c> objMap = new Map<String, Call_Report__c>();
for (Call_Report__c callReport : Trigger.new) {
if (callReport.Custom_Related__c != NULL) {
objMap.put(callReport.Custom_Related__c, callReport);
}
}
List<Call_Report__c> customObj = [SELECT Custom_Related__c FROM Call_Report__c];
List<String> finalcustomObj = new List<String>();
for (Integer i=0; i<customObj.size(); i++) {
finalcustomObj.add(customObj.get(i).split(',')); // error: split is not a method
// Custom_Related__c is a long text field, with a String of recordIds separated by commas
}