UI Action to redirect incident.do page with auto populate fields

AnilM99
Tera Expert

Hi Team,

 

I created UI action (Create Inc) on RITM 

If we click on Create Inc then it should redirect's to Incident.do page with auto populate fields of RITM.

Ex.

Caller = Assigned to

Short description = short description

Description = description

Priority = Priority 

Assignment group = Assignement group

 

Help me on the Same

Thanks Anil!

 

1 ACCEPTED SOLUTION

Karan Chhabra6
Mega Sage
Mega Sage

Hi @AnilM99 ,

 

Create an UI action form button, select the 'client checkbox' and mention the onclick function, you can copy the below script, it should work

KaranChhabra6_0-1682970238052.png

KaranChhabra6_1-1682970948915.png

 

UI Action script

function openIncident() {

    var query = 'caller_id=' + g_form.getValue('assigned_to') + '^short_description=' +  g_form.getValue('short_description') + '^description=' + g_form.getValue('description') + '^priority=' + g_form.getValue('priority') + '^assignment_group=' + g_form.getValue('assignment_group');
    var url = new GlideURL('incident.do');
    url.addParam('sys_id', '-1');
    url.addParam('sysparm_stack', 'no');
    url.addParam('sysparm_query', query);
    var w = getTopWindow();
    var newWindow = w.open(url.getURL(), "_blank");
    newWindow.focus();

}

 

If my answer has helped with your question, please mark it as helpful and accepted solution.

 

Thanks,

Karan

 

 

View solution in original post

5 REPLIES 5

I liked the pattern of your response (Amit Gujarathi) but found out that '&' shouldn't be used:
eg the lines similar to:

url += "&priority=" + encodeURIComponent(priority);

 need the ampersand (&) changed to the caret (^), which works.