Calling script include from notification (email) script not passing parameter

litchick10
Tera Guru

I have a script includes that works correctly when calling via a catalog item, however, I'm trying to call the same script include via notification script and it does not appear to be passing the parameter, what am I doing wrong. 


Script Includes:

 

 

 

var NotaryInstructions = Class.create();
NotaryInstructions.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    getNotification: function() {
        var sysIDType = this.getParameter('sysparm_query_sysIDType');
        var parameters = sysIDType.split(',');
        var sysID = parameters[0]; //used to look up records, excluded from this script for brevity
        var n_type = parameters[1]; //used to set content
       var html = '';
 if(n_type == 'instructions'){
        html = '<p>This is the instructions</p>';
      } else { 
       html = '<p>This is the other return value</p>';
     }
  return html;
    },
    type: 'NotaryInstructions'
});

 

 

 


Notification Script:

NOTE: I also tried using GlideAjax but the log showed that GlideAjax was not recognized as a function from the Notification Script. 

 

 

 

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {
    var state = current.u_state;

    var parameters = current.sys_id + ',instructions';
    var helper = new NotaryInstructions();
    var instructions = helper.getInstructions(parameters); 

    email.setSubject("Notary Commission Instructions for the state of " + state.toUpperCase());
    //email.setBody(instructions);
    template.print(instructions);	

})(current, template, email, email_action, event);

 

 

 

 

Notification Outputs

litchick10_0-1718665553873.png

 

 

1 ACCEPTED SOLUTION

We were able to get Developer Support from SNOW and it was the Script includes that needed modified to add an if statement if undefined:

 

var NotaryInstructions = Class.create();
NotaryInstructions.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    getNotification: function(sysIDType) {
        if (typeof sysIDType === 'undefined') {
            sysIDType = this.getParameter('sysparm_query_sysIDType');
        }
        var sysID = parameters[0]; //used to look up records, excluded from this script for brevity
        var n_type = parameters[1]; //used to set content
       var html = '';
 if(n_type == 'instructions'){
        html = '<p>This is the instructions</p>';
      } else { 
       html = '<p>This is the other return value</p>';
     }
  return html;
    },

	type: 'NotaryInstructions'
});

 

Also a couple of minor edits on the notification script:

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {
    //Get state
    var state = current.u_state;

    var sysIDType = current.sys_id + ',instructions';
    var helper = new NotaryInstructions();
    var instructions = helper.getNotification(sysIDType);
    email.setSubject("Notary Commission Instructions for the state of " + state.toUpperCase());
    email.setBody(instructions);

})(current, template, email, email_action, event);

View solution in original post

6 REPLIES 6

@litchick10 

 

Please refer the Script Include and the Email Script I have provided and compare it with your implementation. As already highlighted by @Kris Moncada , I could also see many things missing. 

 

Thanks and Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

We were able to get Developer Support from SNOW and it was the Script includes that needed modified to add an if statement if undefined:

 

var NotaryInstructions = Class.create();
NotaryInstructions.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    getNotification: function(sysIDType) {
        if (typeof sysIDType === 'undefined') {
            sysIDType = this.getParameter('sysparm_query_sysIDType');
        }
        var sysID = parameters[0]; //used to look up records, excluded from this script for brevity
        var n_type = parameters[1]; //used to set content
       var html = '';
 if(n_type == 'instructions'){
        html = '<p>This is the instructions</p>';
      } else { 
       html = '<p>This is the other return value</p>';
     }
  return html;
    },

	type: 'NotaryInstructions'
});

 

Also a couple of minor edits on the notification script:

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {
    //Get state
    var state = current.u_state;

    var sysIDType = current.sys_id + ',instructions';
    var helper = new NotaryInstructions();
    var instructions = helper.getNotification(sysIDType);
    email.setSubject("Notary Commission Instructions for the state of " + state.toUpperCase());
    email.setBody(instructions);

})(current, template, email, email_action, event);