- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2017 10:25 AM
To all experts,
Here I am again to search for answers to a request.
There is a Record Producer to generate records for all training requests.
There is an email sent to the manager to ask him/her to submit a detailed request (a catalog item). The detailed request will be reviewed by several groups in the enterprise.
The email to the requester's manager contains the Training ticket number, requester name, date, location, and manager's information. Also it sends the link of the new blank Detailed request catalog item.
Below is the email contents.
Please use the information below and click <a href="some link here" >the link to access Training Request Details</a>.
Number: ${u_number} (from the based training request record)
Full name: ${u_full_name}
Employee ID: ${u_employee_id}
Start date: ${u_training_start}
Date end: ${u_date_end}
Title: ${u_associate_title}
Manager: ${u_manager}
Cost center: ${u_cost_center}
Location: ${u_location}
Department: ${u_department}
The requirement states when the manager click the link in the email to fill out a new detailed request all information in the email should be auto-populated. The manager can just fill out the rest details in a new catalog item. How can I achieve the requirement?
I looked at few posts in the ServiceNow wiki and online articles I tried but it did not do anything. So, I am not sure if that is what I am looking for.
Please advise.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-23-2017 07:59 AM
I tried few more code and parameters fixes in the past couple days and I have resolved the issue now.
I removed the default value of the ticket number and decoded the sys_myparm in %26sys_myparm%3D format.
The default value was overlooked.
Thank you, Michael.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2017 07:35 AM
Hi Michael,
I tried use the regex code but it still did not populate anything.
What did I miss?
Thank you,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2017 07:57 AM
I used alert and it returns Ticket Number:
So, what did I miss to cause the URL parameter was not read?
Thank you,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2017 08:18 AM
This code worked for me in a quick test I did in my demo instance. What do you mean by "used alert and it returns Ticket Number"? If you are using the code you posted above, then ticketNum is using the code to get the value from the URL parameter so it appears to be working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2017 10:18 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2017 10:28 AM
Below is my clickable link in the email notification:
<a href="instance link uri=/com.glideapp.servicecatalog_cat_item_view.do%3Fv%3D1%26sysparm_id%3D9bbb0612db63be002a9df2b6af961975&sys_myparm=${u_number}" >
onLoad catalog client script:
function onLoad() {
//Type appropriate comment here, and begin script below
var ticketNum = getParameterValue('sys_myparm');
//alert("Ticket number: " + ticketNum);
if(ticketNum) {
g_form.setValue('nh_req_num', ticketNum);
}
}
function getParameterValue(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(top.location);
if (results == null) {
return "";
} else {
return unescape(results[1]);
}
}
my alert message did not return the parameter.