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

Community Alums
Not applicable

Code looks ok to me. One thing I am unlcear on is what the purpose of the 'setRedirectURL()' is? Is that so it refreshes the page? Perhaps the update is not yet complete (async issue) by the time the redirect is called? Can you add a timeout/sleep interval for a few seconds prior to redirect and see if that resolves the issue?



Cheers,



Tim


Played around with some delays but still the same. Reviewing the "Field Watcher", it looks like it successfully hit the server-side.


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);


}


Could you help with the code you wrote for getting scoped issue solved.


Yes, edited the response now.