- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2015 06:23 AM
Hi,
I am looking for a way to empty the watch list field.
I already tried with g_form.setValue('fieldname', '');
I noticed that this field has a reference to user table.
And noticed that you can store more then on user, so it must also be somekind of array.
Can someone help me with a script line or a piece of code to reset the field so it has no values?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2015 08:15 AM
Hi,
After consideration I have decided to use another approach.
I have removed line 17 and 18 from my UI Action script.
Instead of clearing the fields in the UI Action Script, I have added a client script that will clear the fields onLoad.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2015 07:11 AM
Hi Stijn,
I just tested this on my fuji instance with the watch list field and g_form.setValue('watch_list', ''); cleared the user out of the watch list. Are you sure that the user running the script is able to write to the list field and that there are no other runtime errors on the page preventing the script from running?
The list field stores the value as a comma separated list of sys_ids for future reference.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2015 07:37 AM
Hi Brad,
Thanks for your quick response.
Maybe I should give you more context.
My version is Calgary.
I am not actually clearing the "watch list" field but a similar custom made field.
I have created a UI action that I am using to create a popup on a certain record.
And all functionalities in the script are working except line 18, clearing the "watch field".
Eventhough I am performing the same action on line 17 for a string field.
function showMyForm(){
//Get the table name and sys_id of the record
var tableName = 'u_coha';
var sysID = g_form.getUniqueValue();
//Create and open the dialog form
var dialog = new GlideDialogForm('Send Coha Attachment', tableName); //Provide dialog title and table name
dialog.setSysID(sysID); //Pass in sys_id to edit existing record, -1 to create new record
dialog.addParm('sysparm_view', 'popup'); //Specify a form view
dialog.addParm('sysparm_form_only', 'true'); //Add or remove related lists
dialog.setLoadCallback(function(iframeDoc) {
// To get the iframe: document.defaultView in non-IE, document.parentWindow in IE
var dialogFrame = 'defaultView' in iframeDoc ? iframeDoc.defaultView : iframeDoc.parentWindow;
dialogFrame.g_form.setValue('u_message', '');
dialogFrame.g_form.setValue('u_send_to', '');
dialogFrame = null;
});
dialog.render(); //Open the dialog
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2015 08:15 AM
Hi,
After consideration I have decided to use another approach.
I have removed line 17 and 18 from my UI Action script.
Instead of clearing the fields in the UI Action Script, I have added a client script that will clear the fields onLoad.