- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wednesday - last edited Wednesday
Hi,
This challenge may be too far-fetched but here goes nothing. Our users submit a request for software license activations and renewals. When a software license is due to expire soon, our users can submit a request, and our catalog has a variable asking the user to indicate whether the request is for a new license or renewal and if renewal, to select the expiring request number. When our users select the previous request number, the rest of the variables on the catalog are automatically populated with information from the previous request. We're able to accomplish this using an On Change client script and a script include.
Client Script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
if (g_form.getValue('license_type) == 'Renewal') {
var slRequest = new GlideAjax('sc_task.SoftwareLicenseClientScript);
slRequest.addParam('sysparm_name', 'getLicenseDetails');
slRequest.addParam('sysparm_taskID', g_form.getValue('previous_license_number'));
slRequest.getXML(autopopulateVariables);
function autopopulateVariables(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer) {
var jsonObj = JSON.parse(answer);
if (jsonObj.previous_version) {
g_form.setValue('previous_version', jsonObj.previous_version);
}
if (jsonObj.license_validity_start_date) {
g_form.setValue('license_validity_date', jsonObj.license_validity_date);
}
if (jsonObj.expected_renewal_date) {
g_form.setValue('expected_renewal_date', jsonObj.expected_renewal_date);
}
}
}Script Include:
var SoftwareLicenseClientScript= Class.create();
SoftwareLicenseClientScript.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getLicenseDetails: function(previous_license_number) {
var licenseDetails = {};
var slID = this.getParameter('sysparm_taskID');
if (slID) {
var scTask= new GlideRecord('sc_task');
if (scTask.get(slID)) {
if (scTask.variables.previous_version) {
licenseDetails .previous_version= scTask.variables.previous_version.toString();
} else {
licenseDetails .previous_version= "";
}
if (scTask.variables.license_validity_start_date) {
licenseDetails .license_validity_start_date= scTask.variables.license_validity_start_date.toString();
} else {
licenseDetails .license_validity_start_date= "";
}
if (scTask.variables.expected_renewal_date) {
licenseDetails .expected_renewal_date= scTask.variables.expected_renewal_date.toString();
} else {
licenseDetails .expected_renewal_date= "";
}
}
return JSON.stringify(licenseDetails);
},
type: 'SoftwareLicenseClientScript'
});
My question is, am I able to accomplish this using a hyperlink or button on an email notification? We've built a flow that notifies users when a license is due to the expire that contains the previous license request number and there is a button on the email that when the user clicks on it, it opens a new tab on the user's browser with the Catalog Item/Record Producer. Currently, users are having to manually select Renewal and manually select the License Request Number and then our client script and script include kicks in to populate the rest of the variables, but I would like to be able to have all the variables automatically populated with information from the previous license request number by just clicking the button on the notification.
If this can be accomplished, can someone point me in the right direction? I can't do a client script on an email notification, but could I use a mail script? I'm not sure how I can store values in a mail script and then when a browser tab opens up, copy the values from the mail script and populate it into the variables on the browser tab.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wednesday
in the email which goes, if you are including link to catalog item, then you can send the previous license number as URL parameter and then grab it from URL and then auto populate
somewhat similar solution I shared recently, see that and enhance
need help in auto populating catalog item 1 variable values in to catalog item 2 variables
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wednesday
in the email which goes, if you are including link to catalog item, then you can send the previous license number as URL parameter and then grab it from URL and then auto populate
somewhat similar solution I shared recently, see that and enhance
need help in auto populating catalog item 1 variable values in to catalog item 2 variables
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wednesday
Hi @Ankur Bawiskar thank you as always for the quick response! Let me try your solution and I will report back!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wednesday
Hi Neil, to add to Ankur, you can also look into leveraging the Script Actions AND Inbound Email Action functionalities which are both available OOTB.
I Hope this helps!
Cheers,
Alex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wednesday
Sure, do let me know.
if it worked please mark my response as correct and close the thread.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
