Create Change from Incident
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2019 09:02 AM
There is a Create Change button on Incident and I am trying to see why it isn't working.
Qualification is current.incident_state != 7 && gs.hasRole("itil") && gs.fieldExists('incident', 'rfc') && current.rfc.nil()
As far as I know gs.fieldExists is no longer supported. Is this true? And what is that method supposed to do?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2019 10:25 AM
Hi Tahnalos,
The 'rfc' field name is 'Change Request' and this field references the Change Request table 'change_request'. I believe the "gs.fieldExists('incident', 'rfc')" verifies if that field simply exists.
When you see a condition like the one tied to the Create Change button (UI Action), I find it best to break it down using a simple background script (Global scope):
var sysID = 'ff1fbc391bb6fb0015xxxxxxxxxxxx';
var gr = new GlideRecord('incident');
if (gr.get('sys_id', sysID)) {
try {
gs.print("Found rec: '" + gr.number + "'");
gs.print("state: '" + gr.state + "'");
gs.print("field exists: '" + gs.fieldExists('incident', 'rfc') + "'");
gs.print("rfc is null: '" + gr.rfc.nil() + "'");
} catch (err) {
gs.print("Error: " + err);
}
} else {
gs.print("Rec not found. Check sysID.");
}
Output resembles:
*** Script: Found rec: 'INC0000001'
*** Script: state: '1'
*** Script: field exists: 'true'
*** Script: rfc is null: 'true'
Funny thing..., the Incident in my script (above) was not linked to an actual Change Request, but the field was empty (hence null) so if "gs.fieldExists()" is supposed to identify if the current Incident is linked to a Change Request, I don't believe it is working as intended.
BTW... instance is running London.
- Leo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2019 10:45 AM
Thing is, there is ZERO documentation on what fieldExists does, so I must assume it is deprecated.
As a test, I removed the fieldExists operator from the qualification and the rest of the qualifier is working as intended. This is also on a London instance. Given that this is on a UI Action condition and yours is a plain script, I have to wonder if it works differently in both cases.