How To show state field value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2022 12:50 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2022 01:02 AM
Hi @Sagar_pawar
Instead of data.getvalue('state');
Try
data.state.getDisplayValue();
Hope this helps 😊
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2022 01:15 AM
Did you tried on your PDI. Is it working . I tried the same script it's not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2022 01:28 AM - edited ‎12-18-2022 01:32 AM
Yes, it is
var inc= new GlideRecord('incident');
inc.addQuery("sys_id","{sys_id of sample record}");
inc.query();
if(inc.next()){
gs.info(inc.state.getDisplayValue());
}
Result:
*** Script: New
FYI it should work on the client scripts as number of UI actions uses this fuction:
yourintancename/sys_ui_action_list.do?sysparm_query=scriptLIKEgetDisplayValue&sysparm_first_row=1&sysparm_view=&sysparm_choice_query_raw=&sysparm_list_header_search=true
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2022 02:16 AM
Hello @Kashyap G please check the script I want the problem_id field state value.
function checkStateOfProblem() {
var data = g_form.getReference('problem_id', doAlert);
function doAlert(data) {
if (data.getValue('state') == 102 || 1 || 2 || -5) {
alert('you cannot cancel incident ticket because state is ' + data.getValue('state'));
alert((data.state).getDisplayValue());
alert(g_form.getDisplayValue('state'));
} else {
alert('you can cancel' + data.getValue('state'));
}
}
}