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

How to pull salesforce Id
Hi,
Iam trying to pull Salesforce id of record in Account on the basis of a record value (field: Duns number) from the contact
Iam new to Triggers and Apex ..
please help me how to go about this,...
If you're not setting the field of records affected by the original update that fired the trigger, you do need a DML statement. In this case:
All Answers
Hi,
In salesforce id field is used for salesforce record id. So you have to simply make the SOQL on account to get the id. Try the below code as reference:
Trigger GetAccountId on Conatct(before insert)
{
List<id> ids=new list<id>();
For(contact c: trigger.new)
{
Ids.add(c.accountid);
}
For(account a:[select id,name from account where id in : ids])
{
// Do your manipulation here.
}
}
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
Thanks for help..
For(account a:[select id,name from account where id in : ids])
{
Here i tried to update a field that is in account but still field is not updating
}
It can help if you could post your code here so that we can have a look at it. (And use the insert code feature for nice code readability)
Trigger GetAccountId on Contact(before insert, before update)
{
List<id> ids=new list<id>();
For(contact c: trigger.new)
{
Ids.add(c.accountid);
}
For(account a:[select id,name,Update_Value__c from account where id in : ids])
{
System.debug('@@@@@@'+a.id+a.name);
a.Update_Value__c = a.name;
}
}
//here update_value__c is the field in Account object
If you're not setting the field of records affected by the original update that fired the trigger, you do need a DML statement. In this case: