- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2017 11:29 AM
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);
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2017 11:56 AM
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);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2017 11:33 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2017 11:50 AM
Played around with some delays but still the same. Reviewing the "Field Watcher", it looks like it successfully hit the server-side.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2017 11:56 AM
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);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2017 11:59 AM
Could you help with the code you wrote for getting scoped issue solved.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2017 12:03 PM
Yes, edited the response now.