Need to copy incident data to catalog item field on click of create request ui action

Ashwini35
Tera Contributor

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

1 ACCEPTED SOLUTION

@Ashwini35 

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');

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

18 REPLIES 18

Hi Ankur,

I updated the code like this - 

 

client script - 

function onLoad() {

var itss_std_vsvar_requested_for = g_user.getClientData('caller_id');
var itss_std_vsvar_short_description = g_user.getClientData('short_description');
var itss_std_vsvar_detailed_description = g_user.getClientData('description');

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);

}

 

ui action - 

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));

 

gs.getSession().putClientData('caller_id', current.caller_id);
gs.getSession().putClientData('short_description', current.short_description);
gs.getSession().putClientData('description', current.description);

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;

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();
action.setRedirectURL(url);

 

short description and description is coming but caller is not populating in requested for, any guidance on this please ?

@Ashwini35 

what type of variable is caller in catalog item?

both the field and variable should be on same type

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Both are reference fields, do we need to use displayvalue here also?

@Ashwini35 

then it should work fine

are you able to see the value in alert for variable itss_std_vsvar_requested_for ?

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader