Document Template

Vedavalli
Tera Contributor

Hi

I've created a document template on incident table.
var recordId = 'a9a16740c61122760004fe9095b7ddca';(problem sys_id)
var documentTemplateId = '50e6c385db175e10727ee7dcd39619f2';
var pdfName = 'INC_Template.pdf';
new sn_doc.GenerateDocumentAPI().generateDocumentForTask(recordId, documentTemplateId, pdfName);
with this script I'm trying to pass problem record sys_id which the incident attached to generate document for the problem record . but it's showing me the 

sn_doc (GenerateDocumentAPISNC): User do not access to the record

 how to generate document for problem (I'm using incident table to populate incident fields data)
thanks in advance

9 REPLIES 9

Ankur Bawiskar
Tera Patron
Tera Patron

@Vedavalli 

can you share the complete script?

you are running it from scoped app or global scope?

did you try passing INC sysId and see if it works?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

var recordId = 'e7f527c247516a104bde39aa116d4313';(prblm sys_id)
var
documentTemplateId = '31365c90474e62104bde39aa116d4376';
var pdfName = 'Policy Document.pdf';
new sn_doc.GenerateDocumentAPI().generateDocumentForTask(recordId, documentTemplateId, pdfName);

global and i tried with sys_id as well

@Vedavalli 

document template is configured in which scope?

if you are running script from global scope then it should work fine

are you using some complex script in your document template or straight forward field mapping?

may be it's breaking somewhere and hence not working

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Ankur Bawiskar 
it's showing user don't access the record(if it's prblm sys_id)
if it's incident sys_id then it's generating because in document template I've defined incident as table

@Vedavalli 

sorry but you didn't answer my earlier questions

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader