You need to sign in to do that
Don't have an account?
Ankur Srivastava
Value of Name field in OpportunityLineItem populating as NULL in the trigger
I have to insert the value of Name field present in OpportunityLineItem record in another holder object. I am using doing this by an after insert trigger on OpportunityLineItem object. All the other fields are getting inserted on the trigger execution. But the Name field is populating as null in the Holder object.
Sample code: (just for ref.)
List <B> b = new List<B>();
for(OpportunityLineItem opli : Trigger.New )
{
B bi = new B();
bi.Product_Name__c = opli.Name;
b.add(bi);
}
insert b;
I have skipped the other fields in the snippet..
Please let me know how to resolve this.
Sample code: (just for ref.)
List <B> b = new List<B>();
for(OpportunityLineItem opli : Trigger.New )
{
B bi = new B();
bi.Product_Name__c = opli.Name;
b.add(bi);
}
insert b;
I have skipped the other fields in the snippet..
Please let me know how to resolve this.
I have to now modify my code to now select the name field based on the OpportunityLineItemId from Trigger.New. And populate the same to the corresponding field of my holder object.
This approach is though not the best practice, but still can't help.
All Answers
I even executed a SOQL query on my object to check for the value of NAME field.. There I am getting relevant value.
But that value is not populating in my trigger execution
Can you use a formula field for this? Failing that, It sounds like you'll need to do this asynchronously - I'd be inclined to look at time based workflow if you can live with the fact that you can't set the criteria to when the record is created and every time it is edited. If not, you'll need to use an @future call or set up some scheduled apex to fix things up.
I have to now modify my code to now select the name field based on the OpportunityLineItemId from Trigger.New. And populate the same to the corresponding field of my holder object.
This approach is though not the best practice, but still can't help.