- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2023 08:29 AM
I have built out a flow to send out notifications for requests that need to be approved from my client's service catalog. My issue has to do with adding an additional comment to the associated RITM when the approval has sat in the requested state for 6 days. We have some requests that have multiple approvers for a particular request. Since the flow is triggered off a new approval record's creation, the multi-approver ones are making an additional comment on the RITM for each approver. The client only wants one comment made. Is there a way to do this? Your help is greatly appreciated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2023 01:23 PM
I had some trouble with this. We actually found a low code solution! By using the relative operator for lookup record after a doing a wait duration we were able to just query the appropriate RITMs and update the record with an additional comment. By having the trigger be the creation of the sc_request record it removed the multiple postings that was vexing us. Thanks for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2023 10:06 AM
Hi @Erik Stuer ,
Yes, there is a way to achieve this. You can use a script to check if a comment has already been added to the associated RITM for that particular request and if so, you can skip adding another comment. Here is an example of how you could achieve this:
In your flow, when an approval record is created, use a script to retrieve the associated RITM record.
Check if a comment has already been added to the RITM by searching the sys_journal_field table for entries with the RITM number and a specific comment text that you have added.
If a comment is found, do not add another comment. If a comment is not found, add the comment to the RITM using a script.
Here is an example script:
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('number', current.variables.request_item.number);
ritm.query();
if (ritm.next()) {
var commentExists = false;
var commentText = "Your comment text here";
var journal = new GlideRecord('sys_journal_field');
journal.addQuery('element_id', ritm.sys_id);
journal.addQuery('element', 'comments');
journal.addQuery('value', commentText);
journal.query();
if (journal.next()) {
commentExists = true;
}
if (!commentExists) {
var journal = new GlideRecord('sys_journal_field');
journal.element_id = ritm.sys_id;
journal.element = 'comments';
journal.value = commentText;
journal.insert();
}
}
If my response was helpful in resolving the issue, please consider accepting it as a solution by clicking on the ✅Accept solution button and giving it a thumbs up 👍. This will benefit others who may have a similar question in the future.
Thank you!
Ratnakar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2023 12:11 PM
Hey, I work with Erik and I had a question for this as well. Would that script go in a look up record action? and if so would it be on the approval table and then put that script in the conditions?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2023 01:23 PM
I had some trouble with this. We actually found a low code solution! By using the relative operator for lookup record after a doing a wait duration we were able to just query the appropriate RITMs and update the record with an additional comment. By having the trigger be the creation of the sc_request record it removed the multiple postings that was vexing us. Thanks for your help.