- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2015 02:30 AM
I have a field 'Has Attachment'(check box) on task table. I want to set the value on this field based on attachment, i.e., if there is any attachment attached to the form, the field 'Has Attachment' should set to 'true'; or else 'false'
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2015 02:38 AM
Write display business rule or write before insert or update business rule on the form
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id', current.sys_id);
gr.query();
if(gr.getRowCount() <0)
{
// make check box false
}
else
{
//make check box true
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2015 11:48 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2015 12:22 AM
Write before delete BR on table sys_attchmnet and let me know
var att = new GlideRecord('sys_attachment');
att.addQuery('sys_id',current.table_sys_id);
att.query();
gs.log('test attachment ' + att.getRowCount());
if(att.getRowCount()<=1)
{
"u_has_attachment " this field available on task table i told gliderecord inside the if condition and update the record.
I dont know what is the relation to attachment table and task table. I think you must know it
give that ref and filter then update task table
var gr = new GlideRecord('task');
gr.addQuery();//give what you have relation
gr.query();
if(gr.next())
{
gr.u_has_attachment = "false";
gr.update();
}
}