- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2022 11:46 PM
Hi,
I have a requirement when we attach any files in task after close completing the task the file should get deleted. If we use workflow the workflow contains so many items so the changes will be for all items but i need it particularly for 2 items alone. Is there any other way for this requirement?
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2022 02:22 AM
Hi,
then you can use flow designer for this with no script required
Flow triggers when catalog task is closed
Searches for sys_attachment and deletes the record
Remember to save and activate the flow
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2022 11:59 PM
Hi Ramya,
Write an After business rule on your task table as below
Condition : State CHANGES TO closed complete
Request Item.Item IS <Item Name>
Script :
var gr = new GlideRecord("sys_attachment");
gr.addQuery("table_sys_id", current.getUniqueValue());
gr.query();
gr.deleteMultiple();
Mark as correct and helpful if it solved your query.
Regards,
Sumanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2022 01:37 AM
Hi Sumanth,
I'll try this, thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2022 02:30 AM
Feel free to ask if you have further questions or else you can mark an answer as correct and helpful to close the thread.
In general, You can also use below script in workflows or other scripts
var att = new GlideSysAttachment();
att.deleteAll('gliderRecordObject');
Regards,
Sumanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2022 04:40 AM
Hi Sumanth,
Its working, can we keep this business rule for particular variables. To be more clear for my items there are few variables when you select that we get another variable from that variable we get this " we need this requirement for this variable alone. I don't need this when we select any other variable other than the mentioned, it has to run only with the specified variable. can we do it?