You need to sign in to do that
Don't have an account?
Amit Visapurkar 5
Trigger for docusign object
I have a trigger on dsfs__DocuSign_Status__c object which updates the status field on case object. The trigger is firing when i use the send with docusign from another object. i want to know how to make sure that trigger fires only for case and not for any other object.
Below is the trigger
trigger signatureStatus on dsfs__DocuSign_Status__c (after insert,after update) {
Case t=new Case();
for(dsfs__DocuSign_Status__c d:Trigger.New){
if(d.Id!=null){
if(stoprecurssion.runonce()){
d=[SELECT Id,dsfs__Case__r.Signature_Required__c,dsfs__Case__r.Id,dsfs__Case__r.Status,dsfs__Envelope_Status__c FROM dsfs__DocuSign_Status__c WHERE Id=:Trigger.New];
String e=d.dsfs__Case__r.Id;
t=[SELECT ID,Signature_Required__c,Customer_Signature_Status__c,Status FROM CASE WHERE Id=:e];
if(t.Signature_Required__c==true){
t.Customer_Signature_Status__c=d.dsfs__Envelope_Status__c;
update t;
}
}
}
}
}
It's urgent
Below is the trigger
trigger signatureStatus on dsfs__DocuSign_Status__c (after insert,after update) {
Case t=new Case();
for(dsfs__DocuSign_Status__c d:Trigger.New){
if(d.Id!=null){
if(stoprecurssion.runonce()){
d=[SELECT Id,dsfs__Case__r.Signature_Required__c,dsfs__Case__r.Id,dsfs__Case__r.Status,dsfs__Envelope_Status__c FROM dsfs__DocuSign_Status__c WHERE Id=:Trigger.New];
String e=d.dsfs__Case__r.Id;
t=[SELECT ID,Signature_Required__c,Customer_Signature_Status__c,Status FROM CASE WHERE Id=:e];
if(t.Signature_Required__c==true){
t.Customer_Signature_Status__c=d.dsfs__Envelope_Status__c;
update t;
}
}
}
}
}
It's urgent
Also on a side note - you seem to have multilpe queries inside a for loop which is not a recommended practice. You may need to bulkify your code a bit!
1. Put this query at the begining of the trigger:
This is assuming that your "dsfs__Case__r.Id" field stores the Id value of the Case record. If not, substitute that field accordingly which does so.
2. Put the rest of the logic you want to use under the condition that this list is not empty: