How to set Yes/No based on sn_si_incident table cmdb_ci matched
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-10-2025 12:59 AM
Hello All,
I need a requirement like when i raise a request in Hardware Refresh Model than a task will create and in SCTASK there is a field investigation_resolution_code option when i select lost or Stolen in this dropdown based on this need to check sn_si_incident table assets is linked with cmdb_ci and if its present than set yes or no in below new field that is sir_submitted.
We will create a new read-only field called āSIR Submitted:ā that will have Yes/No values. If the asset is marked as Lost or Stolen this field will appear and we will query the SIR table for a record from the user for the device ID or cmdb_ci. If a record exists we will set the field value to āYesā, if not the value is āNoā. The goal here is to NOT grant access to the SIR record for the user so this search needs to be performed on the backend and will not be editable by the user.
Thank You!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-10-2025 08:29 PM
Where do you want to implement this scenario?
Is it flow or workflow or BR?
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-10-2025 09:35 PM
Hello Murthy
Need to implement this in SCTASK when mapping sn_si_incident table cmdb_ci and this need to be done by Script Include and Client Scripts.
Thank You!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-10-2025 11:26 PM
Hi @Ajay Singh2
Let give my script a try. Just need to change the field name and choice value according to your case.
Client Script OnChange investigation_resolution_code
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
if (newValue === '' || (newValue !== 'Lost' && newValue !== 'Stolen')) { //replace your choice value for Lost and Stolen
g_form.setValue('sir_submitted', '');
return;
}
var ga = new GlideAjax('HardwareRequestUtils');
ga.addParam('sysparm_name', 'sirSubmitted');
ga.addParam('sysparm_device_id', g_form.getValue('<your_asset_variable>')); //replace your variable for asset or ci
ga.getXMLAnswer(function(response) {
if (response === 'true') {
g_form.setValue('sir_submitted', 'Yes');
return;
}
g_form.setValue('sir_submitted', 'No');
});
}
Script Include Client Callable
var HardwareRequestUtils = Class.create();
HardwareRequestUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
sirSubmitted: function(){
var deviceId = this.getParameter('sysparm_device_id');
var grSIR = new GlideRecord('sn_si_incident');
grSIR.addQuery('cmdb_ci', deviceId); //replace field name for asset or ci
grSIR.query();
return grSIR.hasNext();
},
type: 'HardwareRequestUtils'
});
Cheers,
Tai Vu