You need to sign in to do that
Don't have an account?
Simple Trigger Help Needed
Needing help with a simple trigger. I have a value in a custom field on a Custom Object. I want to query Accounts to find the AccountId where the custom field value on my Custom Object = the value of a custom field value on Account. I then want to insert the AccountId into a lookup field on the Custom Object. Help is much appreciated.
trigger recordUpdate on Custom_Object__c (after insert, after update)
{
String a = // need to create a variable for the value of a custom_field__c (text) on Custom_Object__c
List<Id> accountId= [SELECT Id FROM Account WHERE account_custom_field__c = :a];
insert // not sure how to then insert the value of accountId to a different custom field on Custom_Object__c
}
trigger recordUpdate on Custom_Object__c (after insert, after update)
{
String a = // need to create a variable for the value of a custom_field__c (text) on Custom_Object__c
List<Id> accountId= [SELECT Id FROM Account WHERE account_custom_field__c = :a];
insert // not sure how to then insert the value of accountId to a different custom field on Custom_Object__c
}
What exactly you wants to do with this trigger.
what is a in the trigger and what you are trying to insert.
Thanks,
pRAMODH.
what is String a = in your trigger. does this matches to your account.
after querying this List<Id> accountId= [SELECT Id FROM Account WHERE account_custom_field__c = :a];.
if you get more than one value which value you wanna insert to that record.
If you dont know much about trigger please go through the documentation or try to understand what exactly the triggers in Salesforce.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers.htm