> ## Documentation Index
> Fetch the complete documentation index at: https://superofficeas-bugfix-ty-screen-designer-paradox.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Quote document

> How to work with quote documents in CRMScript.

## Locate quote document

```crmscript! theme={null}
NSQuoteAgent qa;
NSQuoteEntity quote = qa.GetQuoteEntity(1);

Integer docId = quote.GetDocumentId();

printLine("The main document is " + docId.toString());
```

## Generate quote document

`GenerateQuoteDocuments()` will generate all the documents required to send the quote as an email to the prospect.

```crmscript! theme={null}
NSQuoteAgent qa;
NSQuotePublishDocuments docs = qa.GenerateQuoteDocuments(2,1,true,0,false,"Super proposal");

Integer docId = docs.GetQuoteDocumentId();

NSDocumentAgent docAgent;
NSDocumentEntity doc = docAgent.GetDocumentEntity(docId);
printLine(doc.GetContact().GetName());
```

### Parameters

* ID of the version
* ID of the template for the email body
* should the main quote document be attached to the email? (bool)
* ID of the template for the quote lines (can be 0)
* Should the attachments specified (in the database) be included? (bool)
* Subject line for the email, in the correct language (can contain template variables)

## Check when a document was sent

```crmscript theme={null}
NSQuoteAgent qa;
NSQuoteVersion version = qa.GetQuoteVersion(1);

Integer state = version.GetState();

if (state == 6 || state == 8 || state == 9) {
  printLine("Proposal was sent " + GetSentDate().toString());
}
```

## See also

* [Working with documents][1]
* [Template variables][2]

[1]: ../document/index

[2]: ../document/templates
