How To show state field value.

Sagar_pawar
Tera Contributor

HELLO ALL,

I HAVE WRITTEN ONE SCRIPT IN UI ACTION. I WANT TO PRINT THE ACTUAL STATE NOT A BACKEND VALUE SO I CAN PRINT THIS.

THANK YOU.

5 REPLIES 5

Kashyap G
Tera Expert

Hi @Sagar_pawar 

 

Instead of data.getvalue('state');

 

Try

 

data.state.getDisplayValue();

 

Hope this helps ðŸ˜Š

Did you tried on your PDI. Is it working . I tried the same script it's not working.

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

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'));

}
}

}