Issue with g_form in client script

Snehal13
Kilo Sage

g_form.getOption('state','2').text is not returning value in workspace client script. This same line of code works fine in native UI What is wrong here. The client script type is set to All and also tried unchecking global option and adding view as workspace for the client script.

 

What is the alternative to make this work at workspace client script. 

3 REPLIES 3

Tushar
Kilo Sage
Kilo Sage

Hi @Snehal13 ,

 

The g_form.getOption() function is not available in workspace client scripts.

This is because workspace client scripts are executed on the server, and the g_form object is only available on the client.

 

I think you can try using the sys_choice.getChoice() function which should help us to retrieve the value of a choice field.

 

 

var choiceValue = sys_choice.getChoice('state', 2);

if (choiceValue != null) {
  var choiceLabel = choiceValue.label;
} else {
  var choiceLabel = '';
}

 

 

Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!

Regards,
Tushar

Let me try this and get back. Thanks Tushar.

Doesnt work.