Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Salesforce by (13.1k points)

I am loosing the values on record whenever I am trying to pass the map value to the list, and also it is not been updated it. Herewith I have attached the debug code:

USER_DEBUG|[403]|DEBUG|posUpdate record -->Position__c:{Affiliation_Final__c=a03N0000000mQEKIA2, Position_Type__c=Warden, Id=a07N0000000iA6lIAE}

11:21:17.825 (825365000)|SYSTEM_METHOD_EXIT|[403]|System.debug(ANY)

11:21:17.825 (825386000)|SYSTEM_METHOD_ENTRY|[404]|String.valueOf(Object)

11:21:17.825 (825402000)|SYSTEM_METHOD_EXIT|[404]|String.valueOf(Object)

11:21:17.825 (825413000)|SYSTEM_METHOD_ENTRY|[404]|System.debug(ANY)

11:21:17.825 (825418000)|USER_DEBUG|[404]|DEBUG|id ->null

11:21:17.825 (825422000)|SYSTEM_METHOD_EXIT|[404]|System.debug(ANY)

11:21:17.825 (825439000)|SYSTEM_METHOD_ENTRY|[405]|String.valueOf(Object)

11:21:17.825 (825453000)|SYSTEM_METHOD_EXIT|[405]|String.valueOf(Object)

11:21:17.825 (825464000)|SYSTEM_METHOD_ENTRY|[405]|System.debug(ANY)

11:21:17.825 (825468000)|USER_DEBUG|[405]|DEBUG|Affiliation_Final__c ->null

11:21:17.825 (825472000)|SYSTEM_METHOD_EXIT|[405]|System.debug(ANY)

11:21:17.825 (825516000)|DML_BEGIN|[406]|Op:Update|Type:Position__c|Rows:2

11:21:17.826 (826821000)|DML_END|[406]

11:21:17.826 (826971000)|EXCEPTION_THROWN|[406]|System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified

Can anyone help me with this error?

1 Answer

0 votes
by (26.7k points)
edited by

As per the error it seems that you have a posMap where the records are not be inserted or retrieved from the database. So, to do that you can try using upsert operation, which will insert those. You can try like this:

upsert posMap.values();

I hope this will help. 

Want to know more about Salesforce? Watch this video on Salesforce Lightning Tutorial

Want to become a Salesforce Expert? join salesforce developer certification now!

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...