- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2023 08:54 AM
Requirement:
1. Create a checkbox 'primary support' in group table.
2. In Incident form if assignment group is selected in incident form and if that assignment group check box primary support is true then show an alert message.
I have created the checkbox and writtern script to find the name of the assignment group from incident
I have no idea how to find that assignment group checkbox value from incident form script.
Can anyone help please ?
My script
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2023 10:07 AM
Hi @jayaprakash1998 ,
You can try the following for you script :
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var primarySupport = g_form.getReference('assignment_group').u_primary_support; // gets the value of the primary support checkbox ( true or false)
if(primarySupport=='true'){ // if primary Support is true show alert
alert(g_form.getReference('assignment_group').name); // alert with the name of the assingment group
}
}
If that helps please mark my answer as correct / helpful!
And if further help is needed please let me know
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2023 10:16 AM
Hi @jayaprakash1998 ,
You can achieve this by creating an onChange client script & a script include please copy the below code
Client Script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
// Use GlideAjax to check if the primary support checkbox is true for the selected Assignment Group
var ga = new GlideAjax('CheckPrimarySupport');
ga.addParam('sysparm_name', 'checkPrimarySupport');
ga.addParam('sysparm_assignment_group', newValue);
ga.getXMLAnswer(function(response) {
if (response == 'true') {
alert('This Assignment Group is marked as Primary Support.');
}
});
}
Script Include:
Client callable : true
var CheckPrimarySupport = Class.create();
CheckPrimarySupport.prototype = Object.extendsObject(AbstractAjaxProcessor, {
checkPrimarySupport: function() {
var assignmentGroup = this.getParameter('sysparm_assignment_group');
var groupGR = new GlideRecord('sys_user_group');
if (groupGR.get('sys_id', assignmentGroup) && groupGR.primary_support) {
return 'true';
} else {
return 'false';
}
},
type: 'CheckPrima
rySupport'
});
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2023 10:23 AM
Can you try this:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var result = g_form.getReference('assignment_group', myData);
function myData(result){
if(result.u_primary_support+"" == "true"){
alert(result.name);
}
}
}
If my answer solved your issue, please mark my answer as ✅ Correct & 👍Helpful based on the Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2023 11:20 PM
Hello @jayaprakash1998,
You can achieve this functionality using multiple ways.
1. Using getReference() inside an OnChange client script. which is also suggested by @Clara Lemos & @Prince Arora.
2. Using Onchange client script and a script include combined. The scripts are given below.
Client Script:
Table: Incident
Type: OnChange
Field Name: Assignment Group
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ga = new GlideAjax('AssignmentCheckbox'); //Script Include Name
ga.addParam('sysparm_name', 'checkAssignmentCheckbox'); //Script Include function name
ga.addParam('group', newValue);
ga.getXMLAnswer(GetResponse);
function GetResponse(response) {
if (response == 'true') {
alert('Group is primary group');
}
}
}
Script Include:
Client Callable: true
var AssignmentCheckbox = Class.create();
AssignmentCheckbox.prototype = Object.extendsObject(AbstractAjaxProcessor, {
checkAssignmentCheckbox: function() {
var group = this.getParameter('group');
var gr = new GlideRecord('sys_user_group');
gr.addQuery('sys_id', group);
gr.query();
if (gr.next()) {
if (gr.getValue('u_primary_support') == true)
return 'true';
else
return 'false';
}
},
type: 'AssignmentCheckbox'
});
Please Mark my answer helpful and correct if it helps to achieve your requirement.
Shivam Jaiswal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2023 12:12 PM
Hello @jayaprakash1998 ,
Any updates on this one?
Please mark it helpful & correct if it helps you achieve the solution.
Shivam Jaiswal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 02:30 AM
Hello @jayaprakash1998 .
Did you get a chance to try this one?
Kindly mark my answer helpful and correct if it helps to resolves the issue.
Shivam Jaiswal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2023 12:57 AM
Thankyou @Prince Arora @Danish Bhairag2 @Clara Lemos