Flow Designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2024 06:13 AM
Hi All,
I have a requirement to create a Flow Designer which will check if the RITM has already been created for the Requested For user. If 'yes' then it should cancel the Record creation else it should do the same.
How can we achieve this? Can someone plz let me know the logic?
Thanks,
Rooma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2024 06:24 AM
Good day,
There are two ways that come to mind for achieving this. The first is better practice, keeps a good paper-trail and is no-code which makes it easier to maintain. The second is a little bit truer to your initial requirements.
1. Create your Flow in Flow Designer. You trigger should be the Service Catalog (triggered by the item you set it on). Your first flow action should be "Look up record" where you can set your conditions to look up active RITMs for the same user with the same Item value.
Then you would want an IF statement that cancels the current RITM if it found an existing one, otherwise it continues on and does the things that are needed.
The benefit of this approach is you'll have the RITMs created by the user but in a cancelled, inactive state. This makes auditing your user behaviours and troubleshooting/tracking what's happening on your system much easier. It is also clear to the end user when they check their tasks, that it was cancelled. You could even add an update action to add a work note to the client specifying it was cancelled as a duplicate.
Furthermore, there may be some scenarios where raising two of the same thing is OK (perhaps when raising for a colleague who isn't setup in the system yet?) in which case the record can be moved out of a cancelled state or used to create a fresh record without the end user redoing everything.
2. Create an onBefore Submit business rule which uses a GlideQuery to see if this record is a duplicate, then aborts the action. That would look something like this...
var gr = new GlideRecord("sc_req_item");
gr.addActiveQuery();
gr.addQuery("item", current.item");
gr.addQuery("requested_by", current.requested_by);
gr.query();
if (gr.hasNext()) {
gs.addErrorMessage("Duplicate record - aborting submission");
current.setAbortAction(true);
}
The above is rough code but should get you most of the way there.
If this helped, please mark it as helpful. If it solved your query please mark it as a solution. It really helps me out!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2024 08:31 AM
@bradleydebono Thanks for the flow logic, I have started the same way but i am able to understand what to check in the if condition as we do not have any inputs from output from previous step.
Suppose the lookup record finds the RITM then what to check in the if condition as we are not storing any value to be checked in the if.
Thanks,
Rooma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2024 08:37 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2024 08:43 AM
@bradleydebono Can you please tell me the 'IF' action logic. Lookin up for the records have been completed. Please refer the screenshot.