Add Risk Assessment Button to Service Portal Form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2023 05:36 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2023 10:43 PM
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:
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.
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2023 11:21 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2023 12:18 PM
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:
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.
Regards,
Riya Verma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2023 05:52 PM
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.