You need to sign in to do that
Don't have an account?
randombard
Insert Multiple Records
Hi All,
when an opportunity is closed won I want to insert on the account multiple records based on the number selected from a dropdown,
IE. Opp1 closed won Multi Select = 15
15 Account suport token records inserted on the account record.
the account tokens have auto number for the name. in the past I would have used do until and then just counted down until the insert = 0 but I expect that there is a better way to do this with apex.
Thanks in advance.
R
I don't really understand why you would create Accounts from an Opportunity, but what you are looking for is a for-loop.
You would embed this in an after-insert trigger on the Opportunity, and verify that the Stage is correct and that a value has been entered for the "Counter" field before calling this code.
Hope this helps,
Hi Sorry my bad,
We are not creating accounts but the unique support tokens, they get a limited amount of support calles baed on their purchase and when they call in they need to submit that token at the same time.
However your post is really helpful and with minor tweeks will de exactly what i want thank :)
R
I spoke too soon keep getting unexpected token at line 5
instead of:
insert Support_Token__c
do:
insertSupport_Token__c
there is a problem with you trigger - you perform a DML inside a for loop, which will cuase you to hit governer limits quickly.
try this instead:
it should work for you - but i do get the feeling that "isWon" is a formula field - which doesnt fire triggers (problem).
am i right?
wow that looks the buisness but
Variable does not exist: current_num_of_tokens_for_account at line 19 column 54
Do I need to declare it as an integer?
Ok so close with some modification i have got this to at least save however it only created one token no matter how may are set to be created