I want to automate the docusign button when the field status is "pending" in object Product.
Please note i will put the logic in class and make it right , i just wanted to check if this will work first.it isn't at the moment, please help.
trigger IDP_productEnvelope on product__c (after insert , after update) {
list<dsfs__DocuSign_Envelope__c> lstdsfsenv = new list<dsfs__DocuSign_Envelope__c>();
list<dsfs__DocuSign_Envelope_Recipient__c> lstdsfsrec = new list<dsfs__DocuSign_Envelope_Recipient__c>();
list<dsfs__DocuSign_Envelope_Document__c> lstdsfsdoc = new list<dsfs__DocuSign_Envelope_Document__c>();
for (product__c product : Trigger.new) {
if (trigger.isupdate){
if(Product.Status__c!=null){
if (Trigger.oldMap.get(product.Id).Status__c!=Trigger.newMap.get(product.Id).Status__c && product.Status__c.equals('Pending')) {
dsfs__DocuSign_Envelope__c dsfsenv = new dsfs__DocuSign_Envelope__c();
dsfsEnv.dsfs__DocuSign_Email_Subject__c = 'This is a Test Check subject';
lstdsfsenv.add(dsfsenv);
dsfs__DocuSign_Envelope_Recipient__c dsfsrec = new dsfs__DocuSign_Envelope_Recipient__c();
dsfsrec.dsfs__DocuSign_EnvelopeID__c = dsfsenv.id;
lstdsfsrec.add(dsfsrec);
}
}
}
if (trigger.isinsert){
if(Product.Status__c!=null){
if (Product.Status__c.equals('Pending')) {
dsfs__DocuSign_Envelope__c dsfsenv = new dsfs__DocuSign_Envelope__c();
dsfsEnv.dsfs__DocuSign_Email_Subject__c = 'This is a Test Check subject';
lstdsfsenv.add(dsfsenv);
dsfs__DocuSign_Envelope_Recipient__c dsfsrec = new dsfs__DocuSign_Envelope_Recipient__c();
dsfsrec.dsfs__DocuSign_EnvelopeID__c = dsfsenv.id;
lstdsfsrec.add(dsfsrec);
}
}
}
}
insert lstdsfsenv;
insert lstdsfsrec;
}
I intend to add docusign document object as well but as of now it is not compiling as it shows required field missing in recipient object which i checked on the layout page,the one and only field subject is being used by me.What is the issue, if anyone has worked on in please advice.Thanks