You need to sign in to do that
Don't have an account?
svp
Urgent help
Hi,
I have a requirement like to create a new record based on the picklist value and associate new one to the old
record via look up field on the same object, Is it possible, can someone help how to do this ?
Thanks a lot inadvance.
I have tried like this,but no luck getting errors :-(
sObject oldobj;
if(sObject.picklist_c == 'xxx')
{
sObject newobj = new sObject();
newobj.Field1 = 'sometext';
newobj.Field2 = 'sometext';
// inser newobj.values( );
insert newobj;
}
oldobj.LookupField__c = newobj.Id;
update oldobj;
Thanks& Regards,
newObj variable is defined inside the if, it won't be available outside the if scope.
Regards,
Hengky
All Answers
i think you should use the variable instead of the object name
Regards,
Hengky
Hi,
Thank you for your reply.
It was a Typo mistake. Getting errors with the code in RED color only i.e., lookup old record with new record ( association).
sObject oldobj;
if(oldobj.picklist_c == 'xxx')
{
sObject newobj = new sObject();
newobj.Field1 = 'sometext';
newobj.Field2 = 'sometext';
// inser newobj.values( );
insert newobj;
}
oldobj.LookupField__c = newobj.Id;
update oldobj;
Best Regards,
newObj variable is defined inside the if, it won't be available outside the if scope.
Regards,
Hengky
Thank you very much. I missed that :-(.
Best Regards,
svp.