You need to sign in to do that
Don't have an account?
Rishu
Add record to custom object field with List results -Apex
I have a list of records (say mergelist), Now I want to add this list of records to a custom field (field2) which is on the same object.
You can take reference from this below code:- In case you find any other issue please mention.
If you find your Solution then mark this as the best answer.
Thanks for replying,
The requirement was to-
Import any field1(picklist) and field2(picklist) in field3 (new field of type multi picklist).
I have tried the below code, but it throws an error saying - variable does not exist: field3
List<sObject> ppRecordsToupdate = new List<sObject>();
for(sObject ppRecord : [select id, name, from LLC_BI__Product_Package__c where
(field 1 !=NULL OR field2 != NULL)])
{
if(ppRecord.field1!=Null)
ppRecord.field3 = ppRecord.field1;
if(ppRecord.field2!=Null)
{
if(field3 !=NULL)
ppRecord.field3 += ';' + ppRecord.field2;
else
ppRecord.field3 = ppRecord.field2;
}
if(field3 !=NULL)
ppRecordsToupdate.add(ppRecord);
}
update ppRecordsToupdate;