Issue with g_form in client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 08:32 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 08:40 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 07:49 PM
Let me try this and get back. Thanks Tushar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 06:55 AM
Doesnt work.