Using Document Templates across scopes outside of HR

SleepingCoder
Tera Contributor

Hey All,

This is my first attempt to use Document Templates.  It looks like it will work really well for me by incorporating a template with a script.  So far I have successfully built the HTML template and tested it using the "Preview" button when viewing the template in Document Templates.  Unfortunately, I've been unable trigger the form from the task using an UI Action.  I would assume that I have it setup incorrectly.

 

This is the code I have that is triggered with an onclick UI Action:-

 

 

function exportTaskReport(){
	var recordId = g_form.getUniqueValue();
	documentTemplateId = 'sys id of the template';
	var tblRec = new GlideRecord('custom_task');
	tblRec.get(recordId);
	var gd = new GlideDate();
	var str = gd.getByFormat('yyyy_MMM_dd_hh_mm');
	pdfName= tblRec.getValue('number') + '-' + str + '.pdf';
	new sn_doc.GenerateDocumentAPI().generateDocumentForTask(recordId, documentTemplateId, pdfName);
}

 

When clicking on the "Generate Task Report" from within the task nothing happens and I can't see anything in the System Log.
 
Any suggestions on how I can get this to work would be greatly appreciated.
1 REPLY 1

mmserenityt
Tera Contributor

@SleepingCoder i am assuming no attachments on the "custom task" record?  do you have the Document Templates (sn_doc) plugin?

do you get a cross scope error?  when using sn_doc you may need to create a cross scope acess between document templates and your app....in the restricted caller access table [sys_restricted_caller_access].

  1. Navigate to: System Applications > Application Restricted Caller Access
  2.  create a new record with the following fields:
    1. Source Scope: "your scope"
    2. Source Type: Scope
    3. Status Allowed
    4. Application: Document Templates
    5. Target Scope: Document Templates
    6. Target Type: Scope
    7. Description: Allow Scoped Application to have access to the plugin, Document Templates

I think if sn_doc plugin was installed afterwards there could be glitches as well.  i usually install this plugin from the start