- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2015 01:13 PM
Hi,
The overall goal is to add a set of bookmarks to the edge for all users. My thought was to write this as "schedule script" to be run ON DEMAND.
The initial part of the script as you can see below is to simply remove all previously entered bookmarks by 'title' (i.e. the entire list of bookmarks I want to add will first be deleted then ADDed back in for each user.)
The script returns the records I expect and giving me the correct recored count. The 'canDelete()' tells me I can; but then it fails to actually do the delete.
Any ideas would be most appreciated!
// SCRIPT BEGINS
removeBookmarks();
function removeBookmarks() {
var rec = new GlideRecord("sys_ui_bookmark");
rec.addQuery("title", "TRUST Dashboard");
rec.query();
gs.log("Record Count:: " + rec.getRowCount());
if (rec.canDelete())
gs.log("I can delete this record!");
if (rec.deleteRecord())
gs.log("Record deleted!");
else
gs.log("Record NOT deleted!");
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2015 01:41 PM
Additional info ...
I changed it over to a FIX SCRIPT to get a faster gs.print() and saw whats below... I do not understand why theere would be a NULL_Pointer exception...
*** Script: Record Count:: 1
*** Script: I can delete this record!
updating : java.lang.NullPointerException:
Error during delete of sys_ui_bookmark (Created 😞 no thrown error
*** Script: Record NOT deleted!
[0:00:00.009] Total Time
AND THE ANSWER IS ....
The script requires a rec.next() after rec.query().
The wiki indicates that this method moves the record pointer TO THE NEXT record; but it seems it also moves it to the FIRST record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2015 01:41 PM
Additional info ...
I changed it over to a FIX SCRIPT to get a faster gs.print() and saw whats below... I do not understand why theere would be a NULL_Pointer exception...
*** Script: Record Count:: 1
*** Script: I can delete this record!
updating : java.lang.NullPointerException:
Error during delete of sys_ui_bookmark (Created 😞 no thrown error
*** Script: Record NOT deleted!
[0:00:00.009] Total Time
AND THE ANSWER IS ....
The script requires a rec.next() after rec.query().
The wiki indicates that this method moves the record pointer TO THE NEXT record; but it seems it also moves it to the FIRST record.