After form reload, choice field shows value instead of label

Community Alums
Not applicable

Hi there,

I'm working on a custom table with a choice field that gets its options dynamically filled by a Client Script that way:

g_form.addOption('<field>', <name of a table>, <label the table>);

When I open the dropdown, I see the labels as expected. But when I save the form, I suddenly see the name instead.

Example: I select "Story", but after saving, I see "rm_story".

Does anyone have an idea what I may be doing wrong?

Best regards,

Kosh

1 ACCEPTED SOLUTION

I was referring to the fact there is a Table Name field type that you can use for the field.  You can then look at using an INSTACEOFtask filter to get just tables that are child of task.

View solution in original post

17 REPLIES 17

johansec
Tera Guru

So somewhat hacky but is it acceptable in your case to make the value the same of the label to simplify your life.

 

g_form.addOption(<fieldName>, <choiceValue><choiceLabel>, <targetIndex>);

 

Sorry not any sort of explanation but will probably work. 

DrewW
Mega Sage
Mega Sage

This is because the system cannot find rm_story in the choice selections so it just adds the value to the choice field so you know what it is.  There are two ways to get around this.  Add all of the selections to the choice list and use a client script to remove them and add just the ones that are needed at that time.

The other option is to set the value and label to the same thing.

 

asifnoor
Kilo Patron

You need to add like this and it will work correctly.

g_form.addOption('<field>', 'rm_story', 'Story');

Mark the comment as a correct answer and helpful once worked.

Will this actually work? As drew mentioned this will not create a record in sys_choice table for this to reference after you leave the ticket. 

I thought these would be the two options

g_form.addOption('<field>', 'Story', 'Story');

or ( the hard way )

In the client script 

use glideajax to add this option to the sys_choice table in a script include ( or remove based on the action the user performed )

then do this

g_form.addOption('<field>', 'rm_story', 'Story');

 

Also depending on if this is truly dynamic and not depended on another choice list you can set up a dependency on sys_choice