- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2022 07:36 PM
Hii All,
I have a requirement.
1. Create a new Category 'Service Request'.
2. Create Service Catalog with name 'Service Request for Incidents' with variables - Requestor(Type - Reference), Category (Type - Choice; with same options as in Incident), Short Description(Type - String), Description(Type - String), Currency( Type - Currency).
3. Create UI Action 'Çreate SR' which should be visible only when category is 'Service Request'.
4. On click of this button , it should redirect to catalog created in point no.2 and variables(Caller in Requestor, Category , Currency, SHort Description) should be auto- populated in catalog page with values available in Incident form.
-->I have done 1,2&3 points.
-->im struck at 4th point.
-->please help me in the 4th point how to sort it out.
Thanks,
anjaneyulu.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2022 10:25 AM
Ok thanks - so the reason requester is not getting populated is the name of your variable is actually 'requester', so I updated line 5 of your onLoad 'Incident details' catalog client script accordingly and it is now working:
g_form.setValue('requester', caller);
URL: https://dev89219.service-now.com/sp?id=sc_cat_item&sys_id=75732e4b1b564110dc0f40c6cc4bcb67&sysparm_caller=6fadf5f21bca0110dc0f40c6cc4bcb6b&sysparm_category=Service%20Request&sysparm_shortDescription=wert
Screenshot:
I also went back and set all the choices you created for your Category variable to have Inactive = true since they are no longer needed due to Choice table/field configuration, and this resolved the duplicate Service Request choice issue as well.
If this answer is helpful please mark correct and helpful!
Regards,
Christopher Perry
Regards,
Chris Perry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2022 07:44 PM
Can you share what you have done for point number 3 specifically to understand where exactly are you placing your button, so that can suggest how to proceed on your 4th requirement?
Also share the details when you say you want to auto populate values.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2022 07:55 PM
Hii Shloke,
In 3rd point - I have written condition in ui action(create SR) current.category=='service request'
when we click ui action button(create SR) in any existing incident record it should redirect to catalog form in service portal & autoPopulate incident record details.
Hope you understood what i said here.
Thanks,
Anjaneyulu.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2022 08:26 PM
In that case, you need to create a UI Action on your Incident form and use the script as below:
var url = '/sp?id=sc_cat_item&sys_id=3f1dd0320a0a0b99000a53f7604a2ef9&sysparm_caller='+ current.caller_id +'&sysparm_shortDescription='+ current.short_description+'&sysparm_Category='+current.category;
action.setRedirectURL(url);
Screenshot of UI Action below:
So when you will click on the button on your Incident form it will form the URL with the value which you need and then you need to follow below steps:
1) Write a On Load Catalog Client Script on your Catalog Item and use the script as below:
function onLoad() {
//Use the 'getParameterValue' function below to get the parameter values from the URL
var user = getParameterValue('sysparm_caller');
var ShortDescription = getParameterValue('sysparm_shortDescription');
if (user) {
g_form.setValue('caller', user); // Replace "caller" with your Caller variable
}
if (ShortDescription) {
g_form.setValue('description', user);// Replace "description" with your Variable Name
}
}
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]);
}
}
This way you can add your other variable as well. This is working for me as shown below:
Result:
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2022 09:17 PM
I have given the same solution before itself as mentioned by other experts later. Did you even try that what I have suggested?
Regards,
Shloke
Regards,
Shloke