Pls let me know the issue in the script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2025 12:51 AM
Hi
Please let me know the correction in the script, this script executes fine except the scenario - this script prints the value "Local Support type must be user group." still though there is no record exist in the Point of contact table for the relevant location . please advise the suggestion in the script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2025 11:29 AM
Thanks for reply, i have tried the way which u suggested. but still the value "local support type must be the group". i have tried "try & catch" also and changed with group value user or other also but it didnt works. pls asssist me.
Tested Script:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2025 12:59 PM
thanks for sharing your code.
The problem is in your validateContactType logic: right now it always ends up returning true or behaving incorrectly because the way you are checking User / Group / Other is inconsistent.
Let’s simplify it.
checkifnotgroupContTypes: function(locationId) {
var msg = '';
if (!this.validateContactType(locationId, 'Local Support', 'Group')) {
msg += 'Local Support type must be group.\n';
}
return msg;
},
validateContactType: function(locationId, contactType, requiredType) {
try {
var gr = new GlideRecord('u_location_point_of_contact');
gr.addQuery('u_location', locationId);
gr.addQuery('u_contact_type', contactType);
gr.addQuery('u_active', true);
gr.query();
if (!gr.next()) {
// no record found
return false;
}
var typeValue = gr.getValue('u_group_user'); // value stored: "User", "Group" or "Other"
// Just check if the typeValue matches requiredType
return typeValue == requiredType;
} catch (e) {
gs.error("validateContactType error: " + e.message);
return false;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2025 01:00 PM
@BanuMahalakshmi
Thanks for sharing your code.
The problem is in your validateContactType logic: right now it always ends up returning true or behaving incorrectly because the way you are checking User / Group / Other is inconsistent.
Let’s simplify it.
checkifnotgroupContTypes: function(locationId) {
var msg = '';
if (!this.validateContactType(locationId, 'Local Support', 'Group')) {
msg += 'Local Support type must be group.\n';
}
return msg;
},
validateContactType: function(locationId, contactType, requiredType) {
try {
var gr = new GlideRecord('u_location_point_of_contact');
gr.addQuery('u_location', locationId);
gr.addQuery('u_contact_type', contactType);
gr.addQuery('u_active', true);
gr.query();
if (!gr.next()) {
// no record found
return false;
}
var typeValue = gr.getValue('u_group_user'); // value stored: "User", "Group" or "Other"
// Just check if the typeValue matches requiredType
return typeValue == requiredType;
} catch (e) {
gs.error("validateContactType error: " + e.message);
return false;
}
}