You need to sign in to do that
Don't have an account?
ezhil_k
how to do..?With Trigger or.?
Am developing a custom object "Detail" where am getting details like Name ,Mobile num, Account ID.Am also adding a custom field "Acc Id " in Accounts object. Before saving the Details record, i want to check,whether the Account Id is existing in Accounts..how it can be checked?
If you do something in the same object then can do with workflow and can check accountid__c is not null or not in the criteria section.
If you want to do update in some other object then do that through trigger
trigger CheckAccount on Details__c(before insert,before update){
for(Details__c d : Trigger.new){
if(d.AccountID__c != NULL){
//Do your work
}
else{
//Do your work
}
}
}
If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.
Thanks
Note: Don't put some DML operator to your for statement.
Please let me know if you have any questions.
Thanks,
Samba
i want to check whether the Account Id in " detail " object is present in "account" object,. please provide me a sample code
I think you can try to write this code.
Please let me know if you have any questions.
Thanks,
Samba
is this the right way to proceed?
trigger CheckAccid on Developer_Detail__c (before insert) {
set<String> accid= new Set <String>();
for (Developer_Detail__c dev:Trigger.new){
accid.add(trigger.newmap.get(dev.id).Acc_ID__c);
}
for(Account acc:[select id,Account_ID__c from Account where Account_ID__c in:accid]){
if (acc !=null){
system.debug('accid present');
}
else {
system.debug('accid not present');
}
}