- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2014 10:56 AM
Hi,
I'm trying to use a GlideRecord query to search for a document ID, but it doesn't appear to be working. Does anyone have an example of how to query for a Document ID?
Here's what I have so far.
var email = new GlideRecord('sys_email'); email.addQuery('sys_id',current.table_sys_id); email.query(); while (email.next()) { gs.log("Target record sys_id " + email.target_table + email.instance); gs.log("Attachment created by " + email.sys_created_by); gs.log("Attachment created at " + email.sys_created_on); gs.log("Attachment " + current.sys_id.toString()); }
The email.instance is the document ID field and it does not log anything.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2014 01:50 PM
The issue is the order that things are done.
1) You hit the Client Email button this creates an entry in the sys_email table (with no Target).
2) You add an attachment to the email - This creates the Attachment triggering your business rule (still no target).
3) You hit send the Target (instance) is updated on the email.
Second thought:
Business Rule
when: After
Table: sys_email
Condition: !current.instance.nil()
Script:
var instance = current.instance;
var targetTable = current.target_table;
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id',current.sys_id);
gr.query();
while(gr.next()){
gr.table_sys_id = instance;
gr.table_name = targetTable;
gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2014 01:10 PM
Adding current.update() did not seem to help.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2014 12:11 PM
Correct, same for us.
When the integrated email client is used for any task-table based record and a file is attached, that file will not show up as attachment on the task-table record.
Do you have an idea how to differentiate the attachments? (if they were attached to the task directly or sent via email)