Update values with onCellEdit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2014 10:38 AM
Hi all,
I was working on a client script with allows the user to change the status of a project in the Project list, and in the same action I need to set the Active field to False and refresh the window to see reflected the change in the Active field, is it possible?
This is what I got but doesn't work,
function onCellEdit(sysIDs, table, oldValues, newValue, callback) {
var saveAndClose = true;
if (newValue == "Cancelled") {
g_form.setValue('active', false);
window.open("pm_project_list.do?", "_self");
}
callback(saveAndClose);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2014 01:33 PM
I don't think you can use g_form in the list to set the value.
Why don't you do this in a before update business rule that runs when your field value changes to Cancelled and sets active to false? Then you would just refresh the list in your client script.
Also, you can use g_list.refresh() to reload a list to see the changes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-19-2014 03:51 PM
Hi Brad,
I haven't had the oportunity to thank, works such as you commented, now the issue I have is that the Client Script works first than the Business Rule, so it is not working, any idea what can I do?
This is the Business rule:
When: After Update
if (current.u_project_state.changes()){
current.active = false;
current.update();
}
This is my Client Script:
onCellEdit
Field name: Project State
function onCellEdit(sysIDs, table, oldValues, newValue, callback) {
var saveAndClose = true;
window.open("pm_project_list.do?", "_self");
callback(saveAndClose);
}
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-10-2018 02:02 AM
Can anyone please explain what is the use of "var saveAndClose = true" variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2019 10:43 AM
The variable saveAndClose itself it not technically necessary. All onCellEdit functions are required to have a boolean value passed into the Callback function however. If you give put "true" into callback, then other client scripts that may be pending will continue to run or if there aren't anymore then the record will be updated. If you put "false" into callback then no further scripts run and the record is not updated. Assigning "true" to saveAndClose up front just acts like a by default we're going to assume everything is good to go... then if during the script some condition that comes up that would cause you to not want to allow the update, then you would just set that variable to "false". This allows for best coding practice where you try to have one entry and one exit point for your code.