You need to sign in to do that
Don't have an account?

Get info from different object's field automatically, is it possible?
There is a custom picklist field (payment__c) in Account, same as in Quote
Ok, if one people create an Account (also select one payment in it), and then create one opportunity, and then click 'add new Quote', the payment__c will be got automatically before save the quote (because it's same as Account's payment__C).
Is it possible? Anyone can tell me how to do it? Or will one trigger?
Thanks.
You can do it using a "before insert" trigger. You will have to query the picklist value on account and then set it. Look for usage and examples in Apex documentation .
Thanks, I write a trigger, but it didn't work, anyone can help me?
trigger test3 on Account (before insert)
{
Set<Id> setId = new set<Id>();
List<Quote> paymentUpdate = new List<Quote>();
for(Account objAcc : [Select Id, payment_terms__c from Account where Id In: Trigger.new])
{
if(!setId.contains(objAcc.Id))
{
setId.add(objAcc.Id);
string str = objAcc.Id;
paymentUpdate.add(new Quote(Id=str.substring(0,15), payment_terms__c = '100% 30 days after shipping'));
}
}
if (paymentUpdate != null && !paymentUpdate.isEmpty())
Database.update(paymentUpdate);
}
Think of it this way, in a before trigger the trigger.new list is on it's way to the database if you don't stop it or change it. Any changes you make in your trigger go directly into the database without having to call update or insert.
Because it's already known, you don't have to query for fields on the trigger.new objects, and in fact if you do they loose their "magic" of being headed to the databse on the copies you got from the query.
change your for loop to for(Account objAcc:Trigger.new) and get rid of the if and update call at the end and see if that doesn't help things.
Thanks for the advice. I am new to the salesforce, just have limited knowledge with the apex code.
Could you please give a sample code with the function or change with my code?
GREAT THANKS! It's pretty urgent for me!