- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2023 08:15 PM
Hi All,
I have a requirement to convert incident to request, for this I am using oob create request ui action but with this I need to copy few fields data from incident such as caller to requested for, short description of incident to short description of catalog item there are around 11 catalog items for which I have to configure this, can someone please guide me how this can be achieved? Its kind of urgent requirement from the client.
Thanks,
Ashwini
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2023 02:57 AM
try to set session variable and then use it in client script
You can add below code in your ui action
gs.getSession().putClientData('caller_id', current.caller_id);
To take these value in your catalog item you have to write a catalog client script.
You can use the below method to get those value
var user = g_user.getClientData('caller_id');
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2023 11:44 PM
you want to auto-populate variables of catalog item with incident form field values?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2023 11:55 PM
yes, I am using create request ui from incident form on click of it catalog item form opens, I need to prepopulate few fields of incident to catalog item form such as caller= requested for.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2023 12:06 AM
this link has solution; try to enhance it as per your case
Redirect from a UI Action to a Catalog Item and set default values
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2023 12:21 AM
Hi Ankur,
I am trying to build the same code for my requirement can you please refer my below ui action code once -
gs.addInfoMessage(gs.getMessage('Incident will get Cancelled and new service request will be created - please validate any missing values in new task', current.number));
var url = "com.glideapp.servicecatalog_category_view.do?sysparm_parent=1808f7381ba055505e38ff3f034bcb3c&sysparm_catalog=e0d08b13c3330100c8b837659bba8fb4&sysparm_catalog_view=catalog_default&sysparm_view=catalog_default&sysparm_processing_hint=setfield:request.parent=";
url += current.sys_id;
action.setRedirectURL(url);
current.incident_state = 8;
current.active=false;
current.comments = 'Incident will get Cancelled and new service request will be created - please validate any missing values in new task';
current.update();
How should I combine these parameters with my url code -
+ '&sysparm_caller_id=' + caller_id + '&sysparm_business_service=' + business_service + '&sysparmshort_description=' + short_description + '&sysparm_description=' + description +
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2023 01:31 AM
Hi Ankur,
My code seems not be working as expected, will it be possible for you to validate it once?
catalog client script -
function onLoad() {
//Type appropriate comment here, and begin script below
var itss_std_vsvar_requested_for = getParmVal('sysparm_caller_id');
//var = getParmVal('sysparm_business_service');
var itss_std_vsvar_short_description = getParmVal('sysparm_short_description');
var itss_std_vsvar_detailed_description = getParmVal('sysparm_description');
//if(user){
g_form.setValue('itss_std_vsvar_requested_for', itss_std_vsvar_requested_for);
g_form.setValue('itss_std_vsvar_short_description',itss_std_vsvar_short_description);
g_form.setValue('itss_std_vsvar_detailed_description', itss_std_vsvar_detailed_description);
}
var instanceID = getParmVal('sysparm_catalog');
function getParmVal(name){
var url = document.URL.parseQuery();
if (url[name])
return decodeURI(url[name]);
else
return;
}
//}
UI action code -
gs.addInfoMessage(gs.getMessage('Incident will get Cancelled and new service request will be created - please validate any missing values in new task', current.number));
var caller_id = current.caller_id;
var business_service = current.business_service;
var short_description = current.short_description;
var description = current.description;
var street = current.street;
var url = "com.glideapp.servicecatalog_category_view.do?sysparm_parent=1808f7381ba055505e38ff3f034bcb3c&sysparm_catalog=e0d08b13c3330100c8b837659bba8fb4&sysparm_catalog_view=catalog_default&sysparm_view=catalog_default&sysparm_processing_hint=setfield:request.parent="+ '&sysparm_caller_id=' + caller_id + '&sysparm_business_service=' + business_service + '&sysparm_short_description=' + short_description + '&sysparm_description=' + description;
url += current.sys_id;
action.setRedirectURL(url);
current.incident_state = 8;
current.active=false;
current.comments = 'Incident will get Cancelled and new service request will be created - please validate any missing values in new task';
current.update();
Please guide me how to fix this issue, this requirement is about to escalate.