You need to sign in to do that
Don't have an account?
gweston
pre populate an opp field from account
I am trying to pre-populate an opportunity field when creating it from an related account. I think the trigger should look something like this but I keep getting stumped by errors.
trigger populateBillingInfo on Opportunity (before insert) { for(Opportunity o: Trigger.new){ if(o.CCNumber__c == null || o.CCNumber__c.equals('')){ o.CCNumber__c = [Select CCNumber__c from Account Where Id = :o.AccountId]; } } }
And what is the error ??
Is it : "Illegal assignment from LIST<Account> to String"
If yes then change your code to look something like this :
Thanks
Ankit Arora
Blog | Facebook | Blog Page
That was the error and that worked for part of the problem.
Is there a way to do a "before load" trigger. I want the field to populate with a credit card number from the account record that the opportunity is initiated from.
Currently the trigger saves the number when i save the opportunity.
Thank you
GWeston,
The triggers are only fired when the record is saved. There are a few options I can think of for accomplishing what you're doing-
I don't think you can show prefill values using triggers. You need to create a custom VFP for "New Opportunity" and override the "New" of opportunity with that page.
When you click on "New" from related list of opportunity on account it provides your the Account Id in URL. You can use that accountid to get the bill info using "ApexPages.currentPage().getParameters().get('accid')" .
Thanks
Ankit Arora
Blog | Facebook | Blog Page
Sorry!! This is a cross post. But we are on same page :)
Thanks
Ankit Arora
Blog | Facebook | Blog Page
I don't think the url will work because the Credit Card fields on the opportunity are part of an app so I will not have access.