UI Action not updating field

John209
Giga Expert

I've seen this topic multiple times around the community but the solutions on do not seem to work for my code. It updates the field for a brief second then when it loads on the list, it reverts back to the original value.

Table: <Extended_task_table>

Order: 100

Action name: statusupdate

Active: Checked

Show update: Checked

Onclick: statusChange()

Condition: current.state == 10

function statusChange(){

        g_form.setValue('state',20);

        gsftSubmit(null, g_form.getFormElement(), 'statusupdate');

        if (typeof window == 'undefined')

        serverResolve();

        function serverResolve(){

                  current.state = 20;

                  current.update();

                  action.setRedirectURL(current);

        }

}

1 ACCEPTED SOLUTION

John209
Giga Expert

Ah, it was a scoping issue. Had to move the if statement and the serverSide function outside the original function.


Correct:


function statusChange(){


        g_form.setValue('state',20);


        gsftSubmit(null, g_form.getFormElement(), 'statusupdate');


}



if (typeof window == 'undefined')


          serverResolve();




function serverResolve(){


        current.state = 20;


        current.update();


        action.setRedirectURL(current);


}


View solution in original post

10 REPLIES 10

Jaspal Singh
Mega Patron
Mega Patron

Hi John,



Try using below snippet.



function statusChange(){


        //g_form.setValue('state',20);


        gsftSubmit(gel('statusupdate'));




  //     if (typeof window == 'undefined')


        serverResolve();




        function serverResolve(){


                  current.state = 20;


                  current.update();


                  action.setRedirectURL(current);


        }


}


It does change the field value, but does not automatically update the record.


It should ideally as it has current.update(). Could you check in activity once & try testing by commenting action.setRedirectURL(current); line from code.


Still seems to stay on the page after switching the "State".