current.setAbortAction(true) doesn't work in script include called by reference qualifier

abrouf
Kilo Sage

current.setAbortAction(true) doesn't work in client callable "script include" called by advanced reference qualifier (javascript:new MembersAssignQueuefields().MembersAssignQueuefields()) pointing to the fields of sys_user_group table. Info message and group name appearing by recognizing the group members but not aborting database operation i,e data is saving by the fields. Any input or suggestions are greatly appreciated.

var MembersAssignQueuefields = Class.create();
MembersAssignQueuefields.prototype = {
initialize:function() {
},
MembersAssignQueuefields:function() {
var grp = new GlideRecord("sys_user_group");
grp.addQuery("name");
grp.query();
gs.addInfoMessage("Group Name:" + current.getValue("name"));
if(!(gs.getUser().isMemberOf(current.name.getDisplayValue()))) {
gs.addInfoMessage('only members of the group can be assigned to these fields');
current.setAbortAction(true);
return false;
}
},
type: 'MembersAssignQueuefields'
};

5 REPLIES 5

Tony Chatfield1
Kilo Patron

Hi, setAbortAction() is a function for aborting a server script record insert or update

https://developer.servicenow.com/app.do#!/api_doc?v=london&id=r_ScopedGlideRecordSetAbortAction_Bool...

I am not quite sure what your intention is here? but your script is not inserting or updating a record.
Also ‘current’ is not a valid object for your code, as the code is being called by a client script,
if you were inserting or updating a record in grp the syntax would be grp.setAbortAction(true);

Hello Tony, thank you for your quick response. I used this option grp.setAbortAction(true); but no luck.

My intention is "only members of the group can be assigned to the fields" using script include from reference qualifier. This works perfectly using before BR. Do you have any idea when does the database update by combination of reference qualifier and script include, this abort works only before database update like as before BR. How can I make it like this?

Hi, If your only requirement is to filter out assignees based on the assignment group selected into a form then you can use a simple dependency at dictionary level.

Take a look at the assignee field in an OOB vanilla instance, right click and Configure Dictionary, you will see the field has a 'Dependent field' of assignment_group, you just need to replicate this configuration.

 

Otherwsie you need to review documentation and examples of reference quailifers to gain a better understanding of functionality and configuration options, you can see these if you navigate to Dictionary and filter by Reference qual ISNOT empty.

 

SanjivMeher
Kilo Patron
Kilo Patron

You are suppose to write a business rule instead of script include.

Reference qualifier runs when you click on the magnifying glass to show you the list of records.

But to abort a save after selecting that record, you should write a BR.


Please mark this response as correct or helpful if it assisted you with your question.