How to create an UI action button to convert an incident to a Request.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2018 01:05 PM
If an incident was submitted incorrectly and it really needs to be a request I need the Convert to Request to do the following:
1. take you to the Hompage of the Service Catalog so that you can select what type of request it is.
2. After you select the type of request, it pulls the information from the incident to the request, such as caller, additional comments and work notes.
3. Once the request is submitted it displays at the top the Request number and also states that the incident was canceled/deleted/
3. It cancels/deletes the incident automatically.
I have seen scripts in the community for this but not all in one script. I am new to scripting , this would be greatly appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2018 01:16 PM
Hello
See below link this might help you something.
https://community.servicenow.com/community?id=community_blog&sys_id=daecfc84dbb2db40b2102926ca961969
Thanks
Ziaur Rahman
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2018 01:58 PM
That did the trick. But one issue is it's not adding the user info from the incident to the request. Do you know what I can add to make this happen.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2018 10:47 PM
Hi Ziaur,
You can add the following in your UI Action:
var user = 'sysparm_user='+current.cLanguageJavaScript
aller_id;
var url = GlideappCatalogURLGenerator.getItemBaseURLFromGR(item); //item is the request form for redirection
gs.setRedirect(url+'&'+user);
Then you can write an on Load client script to add the user with following:
function onLoad() {
if('sysparm_user')
{ var caller = getParmVal('sysparm_user');
if (caller) {
g_form.setValue('caller_id', caller);
}
}
}
function getParmVal(name) {
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec( window.location.href );
if(results == null){
return "";
}
else{
return unescape(results[1]);
}
This should do the work.
Regards,
Manan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2018 08:39 AM
Is something missing? I am new to scripting. I am getting an error for the UI action.
function transferCase() {
var sysId = g_form.getUniqueValue();
var dialogClass = GlideModal ? GlideModal : GlideDialogWindow;
var dialog = new dialogClass('Transfer incident');
dialog.setTitle(getMessage('Transfer Incident'));
dialog.setPreference('sysparm_sys_id', sysId);
dialog.setPreference('sysparm_table_name', g_form.getTableName());
dialog.setPreference('sysparm_subject_person', g_form.getValue('subject_person'));
dialog.render();
var user = 'sysparm_user='+current.cLanguageJavaScript caller_id;
var url = GlideappCatalogURLGenerator.getItemBaseURLFromGR(item); //item is the request form for redirection
gs.setRedirect(url+'&'+user);
}