How to set Variable from g_modal using UI Action?

miro2
Mega Sage

Hi,

I'm trying to set a variable from g_modal using a UI Action. The goal is to set the value from the button to the variable, but this doesn't work. If I try to save it to any field, then it works properly.

Any thoughts on how to save the value to a variable?
UI Action (client)

miro2_0-1762783190785.png

 

function onClick(g_form) {
    var fields = [{
        type: 'choice',
        name: 'reason',
        label: getMessage('Choose reason'),
        value: getMessage(' -- Select -- '),
        choices: [{
            displayValue: 'Missing details',
            value: 'missing_details'
        },
        {
            displayValue: 'Urgent issue',
            value: 'urgent_issue'
        }],
        mandatory: true
    }];

    g_modal.showFields({
        title: "Select your reason",
        fields: fields,
        size: 'lg'
    }).then(function(fieldValues) {
        g_form.setValue('variables.reason', fieldValues.updatedFields[0].value);
        g_form.save();
    });
}


Modal:

miro2_0-1762783295390.png


Variable editor: empty when reason is seleted

miro2_1-1762783317736.png

 


 

0 REPLIES 0