- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2023 04:57 AM
Hello everybody,
We are trying to automate AD group creation using Microsoft AD Spoke V2.
Before to attemp creation, we want to check if group exists.
If group exists, the action "Does group exist?" returns "true" and stops succefully.
If group is missing, the action fails with error "Invalid group name" and flow stops in error.
Do you know a way to make it work?
Regards,
Loïc
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2023 10:46 PM
Hi @loicthery
what about wrapping the call "Does group exists" with a try-catch-block. That way it is not stopping the execution and you can handle the error accordingly.
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2024 07:49 AM
I tried a "Try-Catch" around the "Does Group Exist" Action, but for some reason it is skipping my error, so that catch never runs (see below):
What is going on???
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2024 02:05 AM
To get the correct behaviour, we copied of the action "Does group exists" and made 2 changes in the step #3 "Post Processing & Error Handling" :
1. Lines 23-29 : we set the output variable and leave the error_message empty
else if (error_message.indexOf(actionErrors.CANT_FIND_OBJECT) != -1) {
resource_name = (errMessage.split("' under:"))[0];
resource_name = (resource_name.split("identity: '")[1]).trim();
if (resource_name == inputs.group_name) {
//error_message = "Invalid Group Name : " + resource_name;
// LTH - 2024-01-16 : If the resource is the expected group, we need to return 'false'
outputs.does_group_exists = false;
error_message = "";
} else
error_message = errorMessages.INVALID_OBJECT_IDENTITY + " : " + resource_name;
2. Line 35 : we throw the error only if needed
// LTH - 2024-01-16 : Throw an error only if the error message is set
if (JSUtil.notNil(error_message)) {
throw new Error(error_message);
}
We now can expect Service Now developpers will enhance the behaviour quickly.
I hope these pieces of code could help 🙂
Have a nice coding day,
Loïc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2024 05:24 AM
So much for low code/no code!
I really wish ServiceNow would clean some of these issues up and get them working properly (as intended), especially since they say they are no longer developing Workflow Editor.