Trouble with Qualify UI Action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2023 10:39 AM
Hello, everybody!
I'm running into an issue when trying to customize the oob "Qualify" stage/step of Demand Management lifecycle/workflow and looking for some help and/or advice.
The business would like to make some related list items mandatory, to move a Demand from "Screening" stage to "Qualified" stage...and I am trying to use the method described in the following link to accomplish this:
Solved: Make entry in related list mandatory - ServiceNow Community
My problem is that the Demand record is being updated even if the Client Script returns false...which is weird to me because the thread that I linked above indicates that it should abandon the update, if it returns false.
...but that is not what is happening. The state is still progressing to "Qualified" even though the onSubmit CS is returning false.
The part of the code in the client script that I am referring to is this part:
if(answer == 'Not Exist') {
alert('ERROR');
return false; }
When I use the "Qualify" UI Action on a demand record, the client script runs and I get the alert "ERROR" (I know that the condition for the related list is not satisfied -- as there is no related record)...but the rest of the update happens (the state changes and the record updates)...even though it should (to my understanding) NOT do that -- rather it should abandon the update and not commit the save (according to the link).
The code for the "Qualify" UI Action is simple:
current.state = '-4';
current.update();
action.setRedirectURL(current);
...and I would think that the "current.update()" part is what is triggering the onSubmit...and since I'm getting the alert, it should see the "Return false" and abandon the changes, no?
Some additional info, I do not have a lot of experience with SPM, my wheelhouse is ITSM and I have this same method working just fine on our incident table, for the time worked related list...it'll will throw an error and not commit the update, unless there is a related record on the time worked related list.
I'm thinking that my issue is related to the stage/state handler for Demand, specifically...and my lack of understanding of which, is what is causing my problem. I am assuming this works in a data-driven way, when it actually doesn't perhaps -- so my "return false" Is doing nothing (the state/stage handler doesn't care about the "return false"??)...
...thoughts? halp??
- Labels:
-
Best Practices
-
Demand Management