Pop Notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2023 02:09 AM - edited 08-07-2023 02:21 AM
Hi SN experts,
I am writing an catalog client script to restrict user to not submit the ticket (on catalog item) if they are part of ServiceDesk assignment group but they can submit the request for others.
Following is the script include :
var CheckAssignmentGroup = Class.create();
CheckAssignmentGroup.prototype = {
initialize: function() {},
type: 'CheckAssignmentGroup'
};
CheckAssignmentGroup.isUserInGroup = function(groupName) {
var user = gs.getUser();
return user.isMemberOf(groupName);
};
and client script is
function onSubmit() {
var groupName = "ServiceDeskDL";
var ga = new GlideAjax('CheckAssignmentGroup');
ga.addParam('sysparm_name', 'isUserInGroup');
ga.addParam('sysparm_groupName', groupName);
ga.getXMLAnswer(function(response) {
if (response == 'true') {
alert("You are already a member of the ServiceDesk DL assignment group. Cannot submit the request.");
return false; // Prevent form submission
} else {
return true; // Allow form submission
}
});
}
Can you please help me on this or assist me the right path.
Regards,
Priyanka
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2023 03:21 AM - edited 08-07-2023 03:30 AM
@PK14 You need to create client callable script include if you want to call it from client scripts. You client script looks good. Create script include as below
Add below code in script section
var CheckAssignmentGroup = Class.create();
CheckAssignmentGroup.prototype = Object.extendsObject(AbstractAjaxProcessor, {
isUserInGroup: function() {
var groupName = this.getParameter('sysparm_groupName');
if (groupName)
return gs.getUser().isMemberOf(groupName);
else
return false;
},
type: 'CheckAssignmentGroup'
});
If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2023 04:58 AM
Hi Sandeep,
I have already checked the client callable field but still the code doesn't seems to be working.
Regards,
Priyanka
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2023 05:20 AM
@PK14 Share your script include and client script code here
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2023 05:30 AM
the main question already consists the script include and client script code
Regards,
Priyanka