- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2023 07:44 AM
Can any one please tell me what this reference qualifier do?
javascript: ['incident', 'problem'].indexOf(current.sys_class_name + '') == -1? '' : 'operational_statusNOT IN' + new OpsStatusFilter('cmdb_ci').by('CreateTask').join()
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2023 07:52 AM
Hi @Alon Grod ,
It is used to filter the available options for a reference field on a Configuration Item (CI) form in ServiceNow. The script uses the indexOf()
method to check if the sys_class_name
of the current record being viewed is "incident" or "problem". If it is not, the reference qualifier is cleared by returning an empty string. If the sys_class_name
is "incident" or "problem", the script then applies a filter to the available options for the "operational_status" field.
The filter is created using the OpsStatusFilter
object, which is being used to filter the options based on the "CreateTask" criteria. The by()
method is used to specify the criteria, in this case it is "CreateTask". And join()
method is used to join the filter.
So, the script is essentially checking if the current record is an incident or problem, and if it is, it filters the available options for the "operational_status" field based on the "CreateTask" criteria. This can be useful in situations where you want to limit the options that are available for a reference field based on certain conditions.
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2023 07:52 AM
Hi @Alon Grod ,
It is used to filter the available options for a reference field on a Configuration Item (CI) form in ServiceNow. The script uses the indexOf()
method to check if the sys_class_name
of the current record being viewed is "incident" or "problem". If it is not, the reference qualifier is cleared by returning an empty string. If the sys_class_name
is "incident" or "problem", the script then applies a filter to the available options for the "operational_status" field.
The filter is created using the OpsStatusFilter
object, which is being used to filter the options based on the "CreateTask" criteria. The by()
method is used to specify the criteria, in this case it is "CreateTask". And join()
method is used to join the filter.
So, the script is essentially checking if the current record is an incident or problem, and if it is, it filters the available options for the "operational_status" field based on the "CreateTask" criteria. This can be useful in situations where you want to limit the options that are available for a reference field based on certain conditions.
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2024 06:53 AM - edited 06-04-2024 06:54 AM
Hi,
Where can we check the "CreateTask" criteria? in which table it exists?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2023 08:06 AM - edited 01-16-2023 08:08 AM
@Alon Grod This will return the list of CI where Operational Status is not one of Retired state.
javascript: ['incident', 'problem'].indexOf(current.sys_class_name + '') == -1? '' : 'operational_statusNOT IN' + new OpsStatusFilter('cmdb_ci').by('CreateTask').join()
To understand the code you can try this in the background script
var inc=new GlideRecord('problem');
inc.setLimit(1);
inc.query();
if(inc.next())
gs.info(['incident', 'problem'].indexOf(inc.sys_class_name + '') == -1?"inside if":"else if")
if the table is incident or problem it will return the list of CI where Operational Status is not one of Retired state.
To understand indexOf you refer link
Regards,
RJ