How do I add getProperty value to my URL?

taofeek93
Tera Contributor

Hi guys,

 

So I'm trying to pass the sys_id of a catalog item inside my url in an email script. I've created sys_property to house the value of my sys_id. Now I'm trying to pass that property as part of my URL. 

Below is the current script that's not working:

 

(function runMailScript(current, template, email, email_action, event) {
	var data = {};
	var instanceURL = gs.getProperty('glide.servlet.uri'); //url of instance
	var uninstall_sys_id = gs.getProperty('glide.uninstall_software_id'); //sys_property of sys_id
	data.table_name = "samp_sw_reclamation_candidate";
	data.software_name = current.getDisplayValue('software_install');
	data.installed_on = current.getDisplayValue('cmdb_ci');
	data.model_name = current.getDisplayValue('software_model');
	data.service_portal_URL = instanceURL +"/home?id=sc_cat_item&sys_id=' +uninstall_sys_id' + &software_install=" + data.software_name + "&installed_on=" + data.installed_on + "&software_model=" + data.model_name;
var link = '<a href="'+data.service_portal_URL+'" style="font-size: 14px; font-family: Arial;">Move account</a>';
    template.print(gs.getMessage('{0}', [link]));
})(current, template, email, email_action, event);

 

 

1 ACCEPTED SOLUTION

kimreverman
Tera Guru

Greetings,

Here's one of our working email scripts...

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template, /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action, /* Optional GlideRecord */ event) {

    /***
	* itil_RITM_link_html - print to template the task request item 
	* link (RITM); used for reference list.
	*
	* current record type is sc_task
	***/
	
    printTaskLinkHtml();

    function printTaskLinkHtml() {
		/***
		* printTaskLinkHtml - collect the sc_task request item information; 
		* format the link; and print link to template 
		*
		* current.request_item
		* current.request_item.sys_id
		* current.request_item.number
		*
		***/
		
        if (current.request_item !== undefined && !current.request_item.nil()) {
            var tbl = "sc_req_item";
            var sysID = current.request_item.sys_id;
            var num = current.request_item.number;
            var link = createLinkForObject(tbl, sysID, num);
            template.print(link);
        }
    }

    function createLinkForObject(strTableName, strSysID, num) {
		/***
		* createLinkForObject - format internal link
		* 
		* strTableName - table name
		* strSysID - record sys_id
		* num - record number
		*
		***/
		
        return '<a href="' + gs.getProperty('glide.servlet.uri') + "nav_to.do?uri=" + gs.generateURL(strTableName, strSysID) + '">' + num + '</a>';
		
    }

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

 

View solution in original post

1 REPLY 1

kimreverman
Tera Guru

Greetings,

Here's one of our working email scripts...

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template, /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action, /* Optional GlideRecord */ event) {

    /***
	* itil_RITM_link_html - print to template the task request item 
	* link (RITM); used for reference list.
	*
	* current record type is sc_task
	***/
	
    printTaskLinkHtml();

    function printTaskLinkHtml() {
		/***
		* printTaskLinkHtml - collect the sc_task request item information; 
		* format the link; and print link to template 
		*
		* current.request_item
		* current.request_item.sys_id
		* current.request_item.number
		*
		***/
		
        if (current.request_item !== undefined && !current.request_item.nil()) {
            var tbl = "sc_req_item";
            var sysID = current.request_item.sys_id;
            var num = current.request_item.number;
            var link = createLinkForObject(tbl, sysID, num);
            template.print(link);
        }
    }

    function createLinkForObject(strTableName, strSysID, num) {
		/***
		* createLinkForObject - format internal link
		* 
		* strTableName - table name
		* strSysID - record sys_id
		* num - record number
		*
		***/
		
        return '<a href="' + gs.getProperty('glide.servlet.uri') + "nav_to.do?uri=" + gs.generateURL(strTableName, strSysID) + '">' + num + '</a>';
		
    }

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