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

Great. Do let me know if you are stuck at anything.

Community Alums
Not applicable

Thanks to your great article, I came further, and I think I'm close to a solution. I am sure I'm just missing a very small detail to get it running as expected. I decided for the Script Include + Advanced reference qualifier, which was actually the solution that I tried in the very beginning of this journey.

However, I got stuck again in the same place where I was last time: I think I did everything as described, but nothing happens when I do the lookup.

This is my Script Include:

var u_getAssignmentTables = Class.create();
u_getAssignmentTables.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
    initialize: function() {},
	
    getAssignmentTables: function() {
        var grTaskTableObject = new GlideRecord('sys_db_object');
        grTaskTableObject.get('name', 'task');
        var taskTableSysId = grTaskTableObject.sys_id;

        var tables = [];
        var grTableObject = new GlideRecord('sys_db_object');
        grTableObject.addActiveQuery();
        grTableObject.addEncodedQuery('super_class=' + taskTableSysId + '^ORname=rm_story');
        grTableObject.query();

        while (grTableObject.next()) {
            tables.push(grTableObject.getValue());
        }

        return 'sys_idIN' + tables;
    },

    type: 'u_getAssignmentTables'
});

And this is how I call it in the Reference qual field:

javascript:new u_getAssignmentTables().getAssignmentTables();

However, I just see "-- None --" when I open the dropdown.

Is it because I'm working in a scoped app?

Replace this line

tables.push(grTableObject.getValue());

WITH

tables.push(grTableObject.getValue("sys_id"));

Community Alums
Not applicable

Ouch, that's awkward. Thanks a lot. Now it works as expected, and I can reduce the complexity of my app a lot.

You made my day. 🙂

Great. Have a good weekend 🙂