You need to sign in to do that
Don't have an account?
Linda 98
Before Insert Trigger not working
Hi,
I have a trigger on quote line items.I have a custom number field on quote line item .Based on that value line items will be duplicated.
If user gives 3 in the custom field value then quote line items will be added in 3 number.
I am using a trigger for this.
Here is my code:
trigger AddingQuoteProducts on QuoteLineItem (before insert,before update) { List<QuoteLineItem> listItem = new List<QuoteLineItem>(); for(QuoteLineItem qLI:trigger.new){ System.debug('*******'+qLI.customfield__c); //////This value comes as null during insert and shows value during update. if(qLI.Customfield__c > 1){ for(Integer i=1;i<qLI.CustomField__c;i++){ QuoteLineItem qLiIt = new QuoteLineItem(); qLiIt.QuoteId = qLI.QuoteId; qLiIt.UnitPrice = qLI.UnitPrice; system.debug('opp.PricebookEntry.Id '+qLI.PricebookEntryId); system.debug('opp.PricebookEntry.Product2.Id '+qLI.PricebookEntry.Product2.Id); qLiIt.PricebookEntryId = qLI.PricebookEntryId; qLiIt.Quantity = qLI.Quantity; listItem.add(qLiIt); } } insert listItem; } }
It works fine in my dev org but not in my org.Also it works on update but not on insert.I dont understand what i am missing.
Please help!!!!!!!I need this ASAP
Other than that my code is fine...:)
Thanks all:)
All Answers
change
I need this ASAP....Any helps please.
Hi,
Have enter the value CustomField__c before u clicked on save button?
If yes means ur code will executed perfectly. else not.
Regards,
Rajesh.
Are you testing this with System administrator User or any other profile User ?
FLS is correct right ?
My trigger worked fine in same sandbox before i refreshed it.I dont understand what is making my custom
Field value as null when i save the record.
I checked the log and nothing is executing except trigger.How can i find what is the problem?please suggest...
Sent from my iPhone
Other than that my code is fine...:)
Thanks all:)