creating a comments field and making it mandatory for approvals on portal view
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2023 10:05 AM - edited 05-25-2023 10:24 AM
Hi
When the Request is approved or rejected using approvals on portal page then I want to make the comments mandatory (need to create a comments field first).
How to achieve this?
something like this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2023 10:13 AM
HI @Rahul Raja Sami ,
I trust you are doing great.
Create a Business Rule: First, create a business rule that triggers when the Requested Item (RITM) is approved or rejected. This rule will run when the approval or rejection occurs and will perform certain actions.
Customize the RITM form: Modify the RITM form to include a mandatory comments field. You can achieve this by adding a new field to the form or marking an existing field as mandatory. This ensures that when the RITM is approved or rejected, the person making the decision must provide comments.
Capture the comments: In the business rule, capture the comments entered by the approver or rejecter. You can use server-side JavaScript or any other scripting language supported by ServiceNow. Retrieve the comments from the form and store them in a variable.
Update the request record: Once you have captured the comments, update the associated request record with the comments provided. This ensures that the comments are linked to the original request.
Display comments on the portal: Modify the portal view to display the approval or rejection comments to the end user who raised the request. You can do this by customizing the relevant portal page or widget. Retrieve the comments from the request record and display them in a user-friendly format on the portal.
// Capture comments from the RITM form
var comments = current.comments;
// Update the associated request record with the comments
var request = new GlideRecord('sc_request');
request.addQuery('ritm', current.request_item);
request.query();
if (request.next()) {
request.comments = comments;
request.update();
}
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
05-25-2023 10:15 AM
hi amit,
can you please go through my question once again, please.