For the complete documentation index, see llms.txt. This page is also available as Markdown.

S-Docs Jobs Testing

This article will cover common and unique use cases that can be tested with SDJobs and through the Developer Console.

Basis Use Case: 1 Record, 1 template

Opportunity opp = [SELECT Id FROM Opportunity WHERE Name Like '%Halli Airport%' LIMIT 1];
SDOC__SDTemplate__c template = [SELECT Id FROM SDOC__SDTemplate__c WHERE Name = 'Opportunity Template'];

SDOC__SDJob__c sdjob = new SDOC__SDJob__c(
    SDOC__ObjAPIName__c='Opportunity', // Object API Name
    SDOC__OID__c=opp.id, // Object ID
    SDOC__Doclist__c=template.id, // Template ID
    SDOC__Start__c=true, // Generate document upon insertion of S-Docs Job
    SDOC__SendEmail__c='0' // Send the email Automatically. Change to 1 
    
);
insert sdjob;

Dynamic List of Templates and Files Included In Email Sent:

Opportunity opp = [SELECT Id FROM Opportunity WHERE Name Like '%Halli Airport%' LIMIT 1];

List<ContentDocumentlink> documents = [SELECT ContentDocument.latestpublishedversionid from ContentDocumentlink where LinkedEntityID=:opp.id];
List<id> documentList = new List<id>();
for (ContentDocumentlink document : documents) {
    documentList.add(document.Id);
}

List<SDOC__SDTemplate__c> templates = [SELECT Id FROM SDOC__SDTemplate__c WHERE Name in ('Opportunity Template','Opportunity Email Template')];
List<id> templateList = new List<id>();
for (SDOC__SDTemplate__c template : templates) {
    templateList.add(template.Id);
}

SDOC__SDJob__c sdjob = new SDOC__SDJob__c(
    SDOC__ObjAPIName__c='Opportunity', // Object API Name
    SDOC__OID__c=opp.id, // Object ID
    SDOC__Doclist__c=String.join(templateList, ','), // Template ID
    SDOC__Start__c=true, // Generate document upon insertion of S-Docs Job
    SDOC__SendEmail__c='1', // Send the email Automatically. Change to 1
    SDOC__Include_All_Related_Files__c=true, 
    SDOC__Fid__c=String.join(documentList, ',')
    
);
insert sdjob;

Last updated

Was this helpful?