When an assessment is completed by stakeholder it needs to be redirected to current demand ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2024 05:02 AM - edited 10-17-2024 05:22 AM
when a stakeholder completes his assessment, it needs to be redirected to current demand, i have created a business rule and a client script but it is not working.
Business rule code:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2024 07:59 AM - edited 10-17-2024 08:01 AM
Hi @VedhR ,
I’ve revised your code for the business rule and client script to ensure proper redirection after the stakeholder completes their assessment. Please find the updated code below:
Business Rule
Make sure the business rule is set to after the record is updated, and adjust the code as follows:
(function executeRule(current, previous) {
var demandID = current.trigger_ID;
var demandURL = '/dmn_demand.do?sys_id=' + demandID;
gs.addInfoMessage('Redirecting to demand record'); // Fixed the quote
gs.getSession().putClientData('redirect_url', demandURL); // Set the redirect URL
// Note: Do not use sendRedirect in a business rule
})(current, previous);
Client Script
The client script looks good; ensure it is set to onLoad. Here’s the code with proper formatting:
function onLoad() {
var redirectURL = g_user.getClientData('redirect_url');
if (redirectURL) {
window.location.href = redirectURL; // Redirect to the URL
}
}
Important Notes:
1. Business Rule Settings:
Ensure the business rule is set to run after the record is updated. If it runs before the update, the client script won't be able to redirect correctly because the changes won't be saved yet.
2. Redirecting with sendRedirect:
The gs.sendRedirect() method won't work in a business rule for redirecting users. Instead, you're already setting the URL in the client data, which is the correct approach.
3. Session Management:
Check that there are no other scripts or conditions interfering with the session data being stored. The putClientData method should work as expected unless overridden elsewhere.
If this helps, please mark it as accepted and helpful!
Thank you,
Siddhesh Jadhav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2024 08:24 AM
Thank you for your response.
I have tried the code but it didn't work
Business rule:
Table: Asmt_assessment_instance
when to run: After update
condition: state is complete
code:
and also here is the Ui action