You need to sign in to do that
Don't have an account?
Emily Phillips
How can I get the value from this map?
I'm trying to assign the value from a map to an opportunity field. There isn't a relationship between the two objects: Opportunity and Custom_Object_1__c. Any help is appreciated!
public static void mapDemo(List<Opportunity> oppList){ Set<Id> userSet = new Set<Id>(); for(Opportunity opp: oppList){ userSet.add(opp.CreatedById); userSet.add(opp.OwnerId); } Map<Id, Id> mapCustomObject = new Map<Id, Id>(); List<Custom_Object_1__c> co1List = [SELECT Id, Special__c, User__c FROM Custom_Object_1__c WHERE User__c IN :userSet]; for(Custom_Object_1__c co1 : co1List){ mapCustomObject.put(co1.User__c, co1.Special__c); } System.debug('mapCustomObject: ' + mapCustomObject); for(Opportunity opp: oppList){ opp.Test_Field__c = mapCustomObject.get(); /* assign Special__c here */ } }
What is the data type of Special__c field on Custom_Object_1__c object?
If it is text then modify the below lines of code.
If this helps, please mark it as best answer.
Thanks!!
All Answers
What is the data type of Special__c field on Custom_Object_1__c object?
If it is text then modify the below lines of code.
If this helps, please mark it as best answer.
Thanks!!
The Special__c field is a lookup field to another custom object. Will your solution still work?
Thank you!
Please let me know if any issues?
Thanks!!