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 08:06 AM
@Maddysunil I can not find the action called -"Query Record" and "Check Condition" under the core application.
Can you tell me where I can find it?
Thanks,
Rooma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2024 06:27 PM
@Rooma1 Instead of that, you can write before insert business rule to abort the action, below is the script:
(function executeRule(current, previous /*null when async*/) {
var requestedForUser = current.requested_for;
// Check if an RITM already exists for the Requested For user
var ritmExists = checkIfRITMExists(requestedForUser);
// If an RITM exists, cancel the record creation
if (ritmExists) {
gs.addErrorMessage("Record creation canceled. An RITM already exists for the Requested For user.");
current.setAbortAction(true);
}
// Otherwise, allow the record creation to proceed
})(current, previous);
function checkIfRITMExists(requestedForUser) {
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('requested_for', requestedForUser);
ritm.query();
return ritm.hasNext();
}
Please mark my answer correct/helpful. Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2024 08:48 AM
Hi @Rooma1, As per my knowledge, a flow can be triggered when a record is created / update or configure with service catalog. Hence, in this scenario I dont think there is a way to abort the sc_req_item recod creation. You can follow the suggestion from @Sarika S Nair1 to have the validation in place.
Regards,
Sunil