> For the complete documentation index, see [llms.txt](https://help.sdocs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.sdocs.com/sdocs/maintenance-and-troubleshooting/legacy-workflows/s-doc-jobs-legacy/s-docs-jobs-testing-1.md).

# 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

```apex
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:

```apex
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;
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.sdocs.com/sdocs/maintenance-and-troubleshooting/legacy-workflows/s-doc-jobs-legacy/s-docs-jobs-testing-1.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
