Attachment in task level

ramesham
Tera Contributor

Hi Team,

 

Any attachment added in the request will be captured under request level but it is not visible under SC task level. We dont want to copy the attachment from Request to task level. However our requirement is whenever there is a new attachment added in the request there should be a work note captured under SC task to notify the assignee about the attachment.

 To achieve this what is the best practice we should follow.

7 REPLIES 7

Sujatha V M
Kilo Patron
Kilo Patron

Hi @ramesham 

You can create a flow as below and have a the attachments related list added to the form, if not visible. 

 

This helps to avoid duplication of attachments as both RITM and Catalog Tasks attachments will be displayed. 

 

SujathaVM_0-1709111017028.png

 

Please mark this as helpful and accept it as a solution if this resolves your query.

 

Thanks, 

Sujatha V.M.

Please mark this as helpful and accept it as a solution if this resolves your query.
Sujatha V.M.

Can you give more details about the flow?

Rajdeep Ganguly
Mega Guru

To achieve this, you can create a Business Rule that triggers when an attachment is added to a Request. This Business Rule will then create a work note in the associated Service Catalog (SC) task. Here are the steps:

1. Navigate to "System Definition > Business Rules".
2. Click on "New" to create a new Business Rule.
3. Give your Business Rule a name, such as "Notify SC Task on New Attachment".
4. Set the table to "sys_attachment".
5. Set "When to run > Advanced" and in the "Filter conditions" script box, add a condition to check if the parent table of the attachment is the Request table.
6. In the "Actions > Advanced" script box, write a script to find the associated SC task and add a work note. You can use GlideRecord to query the SC task table and update the work note field.
7. Save the Business Rule.

Here is a sample script for the Business Rule:

javascript
(function executeRule(current, previous /*null when async*/) {

// Check if the parent table of the attachment is the Request table
if (current.table_name == 'sc_request') {
// Create a new GlideRecord to query the SC task table
var gr = new GlideRecord('sc_task');
// Add a condition to find the SC task associated with the Request
gr.addQuery('request', current.table_sys_id);
gr.query();

// If a SC task is found
if (gr.next()) {
// Add a work note to the SC task
gr.work_notes = 'A new attachment has been added to the associated Request.';
// Update the SC task
gr.update();
}
}

})(current, previous);


Please note that this is a basic example and you may need to adjust the script to fit your exact needs and environment.


nowKB.com

For asking ServiceNow-related questions try this :
For a better and more optimistic result, please visit this website. It uses a Chat Generative Pre-Trained Transformer ( GPT ) technology for solving ServiceNow-related issues.
Link - https://nowgpt.ai/

For the ServiceNow Certified System Administrator exams try this :
https://www.udemy.com/course/servicenow-csa-admin-certification-exam-2023/?couponCode=NOW-DEVELOPER