You need to sign in to do that
Don't have an account?
Shannon Andreas 1
Moving an attachment via trigger
I have created a trigger that will create a contract when a DocuSign is completed. I also need the trigger (or another trigger which seems wrong to me) to move the attachment.
Process is when sending to DocuSign, a DocuSign Status record is created. When the Envelope Status changes to "Completed", the contract is created. IN addition to creating the contract, I need the trigger to "copy" the completed document attachment from the DocuSign Status record to the new contract.
Here is my trigger:
trigger CreateContractDocSignComp on dsfs__DocuSign_Status__c (after update)
{
List<Contract> ctr = new List<Contract>();
for(dsfs__DocuSign_Status__c dsfs : Trigger.new)
{
if(dsfs.dsfs__Envelope_Status__c == 'Completed')
{
Contract c = new Contract(Name = dsfs.Name,
Status = 'Draft',
Total_Contract_Value__c =dsfs.Total_Contract_Value__c,
StartDate = dsfs.Contract_Start_Date__c,
Payment_Status__c = 'Ready to be Invoiced',
AccountId = dsfs.dsfs__Company__c,
Opportunity_Name__c = dsfs.dsfs__Opportunity__c);
ctr.add(c);
}
}
if(ctr.size() > 0)
{
System.debug('-ctr------->'+ctr.size());
insert ctr;
}
}
Thanks!
Shannon
Process is when sending to DocuSign, a DocuSign Status record is created. When the Envelope Status changes to "Completed", the contract is created. IN addition to creating the contract, I need the trigger to "copy" the completed document attachment from the DocuSign Status record to the new contract.
Here is my trigger:
trigger CreateContractDocSignComp on dsfs__DocuSign_Status__c (after update)
{
List<Contract> ctr = new List<Contract>();
for(dsfs__DocuSign_Status__c dsfs : Trigger.new)
{
if(dsfs.dsfs__Envelope_Status__c == 'Completed')
{
Contract c = new Contract(Name = dsfs.Name,
Status = 'Draft',
Total_Contract_Value__c =dsfs.Total_Contract_Value__c,
StartDate = dsfs.Contract_Start_Date__c,
Payment_Status__c = 'Ready to be Invoiced',
AccountId = dsfs.dsfs__Company__c,
Opportunity_Name__c = dsfs.dsfs__Opportunity__c);
ctr.add(c);
}
}
if(ctr.size() > 0)
{
System.debug('-ctr------->'+ctr.size());
insert ctr;
}
}
Thanks!
Shannon
Might need help with a test class ;)
Shannon