Add Risk Assessment Button to Service Portal Form

Megalithe
Tera Expert

Our Service Portal has a data table widget for the Change Request table. Some users create changes via a record producer in the portal.

I want to redirect them to automatically be presented with the risk assessment after the creation
AND/OR have the Risk Assessment accessible via a button on the Change Request form in the portal.

8 REPLIES 8

Amit Gujarathi
Giga Sage
Giga Sage

HI @Megalithe ,
I trust you are doing great.

\

To automatically redirect users to the risk assessment after creating a Change Request, we can use UI policies and client scripts. Here's the solution:

  1. Create a UI policy to show the Risk Assessment field only when a new Change Request is created. This can be done by configuring the UI policy to show the Risk Assessment field based on the condition "State is empty" or any other suitable condition.

  2. Next, create a client script that runs when the Change Request form loads. In this script, check if the Risk Assessment field is visible. If it is, automatically redirect the user to the Risk Assessment form.

Here's an example of the client script:

 

 

 

function onLoad() {
   if (g_form.isVisible('risk_assessment')) {
      window.location.href = '/risk_assessment.do?sys_id=' + g_form.getUniqueValue();
   }
}

 


Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



Hello Amit,
Thank you for your reply. Isn't "window.location.href " prohibited in the service portal, is there a work around to enable this?

Riya Verma
Kilo Sage
Kilo Sage

Hi @Megalithe ,

 

Hope you are doing great.

 

To achieve the desired functionality of redirecting users to the risk assessment after creating a change request via a record producer in the Service Portal, or providing access to the risk assessment through a button on the Change Request form in the portal, we can implement the following solution:

  1. create a new UI Action on the Change Request table that will be responsible for navigating the user to the risk assessment form.

    • Table: Change Request [change_request]
    • Action name: "Risk Assessment"
    • Onclick: Specify the JavaScript function that will redirect the user to the risk assessment form. For example:
       

 

window.open('/risk_assessment.do?sys_id=' + current.sys_id, '_blank');

 

  • Visible: Choose the conditions that determine when the UI Action should be visible to the user, such as when the change request has been created.
  • modify the record producer in the Service Portal to include the redirect functionality after the change request is created.Add the following script to the "Client Script" section:

     

 

function onSubmit() {
  var gr = current.getRefRecord();
  if (gr) {
    // Redirect to the risk assessment form
    window.open('/risk_assessment.do?sys_id=' + gr.sys_id, '_blank');
  }
  return;
}

 

  • Save the changes made to the record producer.

 
Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma

Hello @Riya Verma,

Thank you for your suggestion. Is there an additional configuration that is needed to get window.open to work in the catalog client script or regular client script? From what I am reading this appears to be blocked in the ServicePortal.