Autopulate issue manager based off entity type
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2024 02:51 PM
Hi I have a requirement on the issue table (sn_grc_issue) to autopopulate the issue_manager field to user X if issue_source= indicator failure and the entity referenced in the profile field has entity type (sn_grc_m2m_profile_profile_type) Y.
On the entity (profile) table the entity types are a related list. I attempted to an on load client script calling a script include but it is not working for me. How would I go about achieving this?
Client Script:
function onLoad() {
// Check if the issue_source field matches the specified value
if (g_form.getValue('issue_source') === 'd8000889730323003aebda013ef6a72a') {
g_form.getReference('profile', function(profile) {
if (profile) {
var ga = new GlideAjax('CheckEntityTypeScriptInclude');
ga.addParam('sysparm_name', 'checkEntityType');
ga.addParam('profileSysId', profile.sys_id);
ga.getXMLAnswer(function(response) {
var hasEntityType = response.responseXML.documentElement.getAttribute("answer") === "true";
alert(hasEntityType);
if (hasEntityType) {
g_form.setValue('issue_manager', 'X');
} else {
alert("Profile does not contain the required entity type.");
}
});
} else {
alert('Profile is null or undefined');
}
});
}
}
Script Include:
var CheckEntityTypeScriptInclude = Class.create();
CheckEntityTypeScriptInclude.prototype = {
initialize: function() {},
checkEntityType: function() {
var profileSysId = this.getParameter('profileSysId');
var targetEntityType = '002b84281b755a10f9246204b24bcbcd';
var hasEntityType = false;
var gr = new GlideRecord('sn_grc_m2m_profile_profile_type');
gr.addQuery('profile', profileSysId);
gr.addQuery('profile_type', targetEntityType);
gr.query();
if (gr.next()) {
hasEntityType = true;
}
return hasEntityType.toString();
},
type: 'CheckEntityTypeScriptInclude'
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2024 05:07 AM
Hi Nabilah,
I have a clarification as follows.
An entity can be mapped to multiple entity types, if the entity is mapped to another entity type in future, then this assignment will not work.
Did you try this with configuring the issue group rule provided in the administration module? The best practice is set to utilize the issue group rule configured and mapped against the control objective.