- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2017 03:49 PM
Scripts are not triggering when making updates to records in List View.
There are scripts in place to autopopulate certain fields based on changes ot other fields. For example, on a HW Asset record, if State changes from On Order to In Stock, the Order Received date field should autopopulate with TODAY's date. This works if you edit the record and click Save or Update, but not if you update the State in the List View. This can result in lost or missing data. This is especially true in the above scenario where Deskside may be updating dozens or even a hundred HW Asset records to 'receive' them into inventory. It isn't feasible to update 100 records for the same update (State change) by editing each record in turn. With an average load time approaching 30 seconds between records you are introducing 50 minutes just to open and close records when the list view for same 100 could be updated in 5-7 minutes.
This is the onchange script I have and it works on single form edit. But I want this to trigger changes on list view also (bulk records)
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if(newValue=='disposed'){
var SetDisposedDateObj = new GlideAjax('SetNowDate'); //Calls Script Includes: SetNowDate
SetDisposedDateObj.addParam('sysparm_name','now');
SetDisposedDateObj.getXMLWait();
var disposedDate = SetDisposedDateObj.getAnswer();
g_form.setValue('u_disposed_date', disposedDate);
}
else{
g_form.setValue('u_disposed_date', '');
}
}
What is the best way to script this?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2017 01:34 AM
As Surya has mentioned, onCellEdit is needed for list changes; onChange only works for form changes.
A AfterUpdate BR is safer, since that will trigger no matter which method is used to amend the data. It's also more efficient to use server-side methods over client-side methods.
By the way, is what you're trying to achieve possible with a UI Policy?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-11-2017 04:18 PM
Thank you all. Business Rule worked perfect.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-11-2017 09:41 PM
Hello Rajini,
Let me know if that answered your question. If so, please mark the response as correct/helpful.
Thanks,
Surya Amara
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-11-2017 10:34 PM
Hi Rajinis,
Did you get requirement working. How did you manage the cell edit.
Regards
Param
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2017 07:56 AM