The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Instantly redirecting to another record

conmic
Mega Guru

Hello all,

I have a simple question, but somehow I'm already stuck on it for hours and I hope that you can give me a little jump start.

 

We're using the CALL (table 'new_call') application in order for the customers to open tickets with us and then our Service Desk classifies it accordingly (Incident, Change, etc...). Now we don't want to bother the customers with to many different reference numbers, they will receive the CALL reference number and every other reference (incident, change, etc...) is internal only.

 

Well now to my little blockade:

When the customer is currently on the portal an clicks on the CALL reference, the CALL record opens displaying a message that his Call has been transferred and he needs to click 'here' to view the appropriate Incident, Change, etc... record. this has been realized with a Business Rule.

However we want to avoid this, so that when the customer clicks on the CALL reference, he is instantly redirected to the according Incident, Change, etc... record. Is it possible to do this with the previously mentioned Business Rule? I haven't found and can't think of any appropriate solution...

 

Thank you and

Kind regards,

Michel

1 ACCEPTED SOLUTION

A simpler way to do the same thing is to use an onLoad client script. You would only need one client script instead of the combination of a business rule and a UI policy. However, the client script will also fire only after the form has loaded.



If you want immediate redirection;


  1. create a UI macro with some client-side JavaScript code for redirection
  2. create a UI formatter for your UI macro
  3. add that UI formatter at the very top of the self-service view of the CALL form


As the page code is evaluated top-down, the redirection will be triggered before the form is fully rendered.



Creating a Formatter - ServiceNow Wiki


View solution in original post

12 REPLIES 12

conmic
Mega Guru

I think I figured it out myself, I just don't know if it's to be considered a 'proper' method.


Let me know what you think:



I have modified the mentioned business rule to contain gs.setRedirect()


var sysID = current.transferred_to;


var ctype = current.transferred_to.sys_class_name;


var url = ctype + '.do?sys_id=' + sysID;


gs.flushMessages();


gs.addInfoMessage("This Call was transferred to " + current.transferred_to.getDisplayValue() + ". Please click " + " <a href='" + url + "'>here</a>" + " if you have not been redirected automatically.");


gs.setRedirect(url);



In a second step I created a UI policy with a condition (same for the business rule) to check if the state of the Call is 'transferred' (A custom field 'u_call_state' that I created for the new_call table. Alternatively check if the 'transferred_to' field is not empty.). If the UI policy returns true it executes a script that simply contains:


reloadWindow(window);



This does the trick pretty smoothly for me... but is it really proper? The best way to do this?


The way you have now set it up, does redirection happen before the form has fully loaded or as soon as it has been rendered?


After the form has fully loaded, as the UI policies only apply once the form has loaded.


That's why I still include a message in the Business Rule.



If you have any other idea, please let me know.


A simpler way to do the same thing is to use an onLoad client script. You would only need one client script instead of the combination of a business rule and a UI policy. However, the client script will also fire only after the form has loaded.



If you want immediate redirection;


  1. create a UI macro with some client-side JavaScript code for redirection
  2. create a UI formatter for your UI macro
  3. add that UI formatter at the very top of the self-service view of the CALL form


As the page code is evaluated top-down, the redirection will be triggered before the form is fully rendered.



Creating a Formatter - ServiceNow Wiki