+ Start a Discussion
RishuRishu 

Import field1 and field2 onImport 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;
OFröhlichOFröhlich
Hi,

ppRecord in if clause is missing and a typo in "field 1"

List<sObject> ppRecordsToupdate = new List<sObject>();
for(sObject ppRecord : [select id, name, from LLC_BI__Product_Package__c where
                                           (field1 !=NULL OR field2 != NULL)])
{
    if(ppRecord.field1!=Null)
        ppRecord.field3 = ppRecord.field1;
    if(ppRecord.field2!=Null)
    {
        if(ppRecord.field3 !=NULL)
            ppRecord.field3 += ';' + ppRecord.field2;
        else
            ppRecord.field3 = ppRecord.field2;
    }
    if(ppRecord.field3 !=NULL)
        ppRecordsToupdate.add(ppRecord);
}
update ppRecordsToupdate;

If this helps, please mark as Best Answer to help others too.