How to add URL parameter to redirect

Sirko
Tera Expert

Dear Community,

I'm using an UI action button in the Agent view ("Create Emergency Case") that creates a case. Finally the UI Action uses a redirect:

var url = '/nav_to.do?uri=sn_customerservice_case.do?sys_id='+ newCaseSysId;
action.setRedirectURL(url);

that redirects to the new case. This works fine.

But now I have the requirement that a certain action (prefilling comment field) is only be done in the case form (after redirect) when the case is just created during the UI action. This action should not be done when opening the case using any other usual way.

So I tried to add a parameter to the url: newEmergencyCase=true which can be read from the client script. This works when I add the parameter manually.
I tried to add it to the redirect:

var url = '/nav_to.do?uri=sn_customerservice_case.do?sys_id=' + newCaseSysId + '&newEmergencyCase=true';


But, obviously action.setRedirectURL(url); removes the additional parameter. So I tried:

var url = '/nav_to.do?uri=sn_customerservice_case.do?sys_id=' + newCaseSysId + '?newEmergencyCase=true';


or

var url = '/nav_to.do?uri='+ encodeURIComponent('sn_customerservice_case.do?sys_id=' + newCaseSysId + '?newEmergencyCase=true');


both failed as the URL ends with
...sn_customerservice_case/d515458cc390e21091d56110a00131e8%3FnewEmergencyCase%3Dtrue
and so the "Record not found" due to the Sys_ID seems to be d515458cc390e21091d56110a00131e8%3FnewEmergencyCase%3Dtrue and not only d515458cc390e21091d56110a00131e8.

So my question is:
How do I add a custom parameter to the URL that I can read in the client script like this: ...sn_customerservice_case/d515458cc390e21091d56110a00131e8?newEmergencyCase=true

or:

is there another way to tell the client script when it was called using the UI action?

Thanks
Sirko

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Sirko 

why not move the code to client side and then use window.open and then include URL parameter and fetch it using onLoad

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@Sirko 

why not move the code to client side and then use window.open and then include URL parameter and fetch it using onLoad

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Yes, this is a working way, thanks
Sirko