Create Change from Requested ITEM

Amey8
Tera Guru

I have a requirement to create change request from RITM. I have enabled the UI Action 'Create Change' on the sc_req_item table.

 

Its working but its opening the New change record directly and setting type to 'Normal'

 

I want it to open the model page where i can choose from Standard , Emergency Normal model Types..

 

Amey8_0-1744131159433.png

This is the current UI Action script

var url = new GlideURL("change_request.do");
url.set("sys_id", "-1");
url.set("sysparm_query", "^parent=" + current.sys_id + "^short_description=" + current.number + " - " + current.cat_item.name + "^description=" + current.variables.business_justification + '^u_requested_item=' + current.sys_id);
action.setRedirectURL(url.toString() + "");
 
I tried changing the url but then the UI Action is not clickable.
1 ACCEPTED SOLUTION

Hello @Amey8 ,

 

If you want this UI Action to work both in the core UI and in Workspace you need to make the following changes to it:

 

  • Check the Client checkbox (set to enabled)
  • Set OnClick to:
redirectToCR()​
  • Change the Script to:
function redirectToCR() {
	var url = '/new_change_redirect.do?sn_new_chg_origin=module';
	location.replace(url);
}​
  • Change the Workspace Client Script to:
function onClick(g_form) {
	var url = '/new_change_redirect.do?sn_new_chg_origin=module';
    top.window.open(url, '_blank');
}​

I assume you want the Workspace button to open the URL in a new tab. If this is not the case then use "location.replace", like in the regular script.

 

Regards,

Robert

View solution in original post

9 REPLIES 9

Hello @Aarushi1991 ,

 

Pre-populating some fields (e.g. Parent) on the new Change Request will only work with your original solution, because there you are redirecting to a new Change Request form, which accepts the parameters that you are passing in the URL.

 

But the Change Model landing page or the Standard Change Catalog do not support these URL parameters. They just allow you to select one of the Standard Change Record Producers, which will then create the Change Request record. But at that point the system won't know that you originally came there by clicking some UI Action on a RITM so it can't make the connection between these records.

 

Regards,

Robert

Robert H
Mega Sage

Hello @Amey8 ,

 

The following UI Action code would achieve this:

var url = '/new_change_redirect.do?sn_new_chg_origin=module';
action.setRedirectURL(url);

 

I have noticed that your current solution also pre-populates some fields on the new Change Request. That would not work with the above solution.

An alternative would be that you create more than one UI Action, e.g. "Create Normal Change", "Create Emergency Change". The you could use your existing solution and would just have to add a bit more code that populates the Model and Type fields of the Change Request accordingly.

 

Regards,

Robert

Hi Robert,

 

Thanks for your response. 

I tried the below code, it works perfectly from the native view. I tried adding the below code in the workspace as well.

function onClick() {
    var url = '/new_change_redirect.do?sn_new_chg_origin=module';
    action.setRedirectURL(url);
}
 
But from SOW workspace, it is not working.  
 
Amey8_0-1744606356903.png

 

Hello @Amey8 ,

 

If you want this UI Action to work both in the core UI and in Workspace you need to make the following changes to it:

 

  • Check the Client checkbox (set to enabled)
  • Set OnClick to:
redirectToCR()​
  • Change the Script to:
function redirectToCR() {
	var url = '/new_change_redirect.do?sn_new_chg_origin=module';
	location.replace(url);
}​
  • Change the Workspace Client Script to:
function onClick(g_form) {
	var url = '/new_change_redirect.do?sn_new_chg_origin=module';
    top.window.open(url, '_blank');
}​

I assume you want the Workspace button to open the URL in a new tab. If this is not the case then use "location.replace", like in the regular script.

 

Regards,

Robert

Shivalika
Mega Sage

Hello @Amey8 

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY