g_form.getOption() doesn't work in Workspace - need an alterative

Marc D
Tera Contributor

Hello everyone. My current project has a requirement - when Category is set to a certain value, it adds an extra option to the Subcategory choices. To do this, I created a UI Policy with scripts like these:

Execute if true:

function onCondition() {
    if (!g_form.getOption('subcategory', 9)) {
        g_form.addOption('subcategory', 9, '<insert some name here>');
    }
}

Execute if false:

function onCondition() {
    g_form.removeOption('subcategory', 9);
}

This worked fine at first, but we later discovered that it didn't work when testing in the Workspace. After looking it up, I discovered that g_form.getOption() doesn't work in Workspace. Are there any alternatives I can use? I was using getOption() specifically to check to see if the extra Subcategory choice already existed.

7 REPLIES 7

Hi @Marc D 

 

It is not working in Agent Workspace or in Workspace view ? I tried simulating it on my PDI and I am able to make getOption work in the Workspace view but not in Agent workspace.

 

Thanks & Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

It is not working in Configurable Workspace. Workspace view in classic UI works fine.

In any case, my team decided to instead use dependent values so that this issue won't hurt the project.

RajiniM
Tera Expert

Hi

 

I had the similar situation, I have used getOption in onChange client script to store the oldValue in other field. The script worked fine in Native UI but didn't work in Workspace, after a lot of research I found a alternative solution for this. Used display BR to get internal values

 

Native UI script

   var priority_label = g_form.getOption('priority', oldValue).text;
    g_form.setValue('previous_priority', priority_label);
 
Workspace script
   var priority_label = g_scratchpad.priority;
    g_form.setValue('previous_priority', priority_label);
 
Display BR
g_scratchpad.priority = current.getDisplayValue('priority');
 
Hope this helps!!