Client Script not firing from List view
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2017 01:37 PM
I have a client script which is working perfectly fine in the form view.. If i update a field in the form view, the onChange client script works fine. But if make the change in the List view by double clicking the field, the client script is not working.. Any alternate solution?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2017 04:11 AM
Hi Kailash,
please check the below link it will help you
http://wiki.servicenow.com/index.php?title=Client_Script_Best_Practices#gsc.tab=0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2017 05:10 AM
hello Kailash,
your onchange client works on form level only, if you want to achieve this in list view, again you have to create onCellEdit client script.
I hope this helpful to you, please hit like and helpful and mark as current answer based on your impact.
Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2017 05:14 AM
Please refer below example for your query,
onCellEdit() Scripts
Scripts can be defined as onCellEdit to run on the client side when the list editor interacts with a cell.
Note: onCellEdit scripts do not apply to list widgets on homepages or dashboards. |
An onCellEdit() script must contain a function named onCellEdit().
An onCellEdit() script takes the following parameters:
- sysIDs - An array of the sys_ids for all items being edited.
- table - The table of the items being edited.
- oldValues - The old values of the cells being edited.
- newValue - The new value for the cells being edited.
- callback - A callback that continues the execution of any other related cell edit scripts. If 'true' is passed as a parameter, the other scripts are executed or the change is committed if there are no more scripts. If 'false' is passed as a parameter, any further scripts are not executed and the change is not committed.
Example:
function onCellEdit(sysIDs, table, oldValues, newValue, callback) {
var hasDifferentValues = false;
for (var i = 0; i < oldValues.length; i++)
{ var oldValue = oldValues[i];
if (oldValue != newValue){
hasDifferentValues = true; break;
} }
var success = hasDifferentValues && performSomeFurtherValidation(sysIDs, table, oldValues, newValue); callback(success); }
Refer
http://wiki.servicenow.com/index.php?title=Client_Scripts#gsc.tab=0
Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke