The CreatorCon Call for Content is officially open! Get started here.

To add client condition in attachment action by using javascript:

pratikshabh
Tera Contributor

I want to fetch attachment sys ids in a filter where action model field is used which attachmentSysId.Screenshot 2025-08-19 225306.png

 

I have added condition like this but it is not showing attachment action on the form even if the attachments are getting added. I have tried the same code in attachment table by using sys is one of it is showing those sys_ids. Could you suggest something to add condition 

14 REPLIES 14

In attachment action there is one action called as removal I need to show it only if the the field in respective attachment record is true. Please refer removal  attachment action attachment for the same

pratikshabh_0-1755695546359.png

 

@pratikshabh 

So are you saying based on INC field value that option should be shown?

If yes then you can use Script Condition and pass the current.sys_id to script include

if the current.sys_id -> is sys_attachment sysId then query that table record with sysId and check the field value

I am not sure how that action assignment is created and how it came in that attachment option

Share screenshots for that so that I can try in my instance

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

pratikshabh_0-1755786096629.png

I want to check if selected attachment is having checkbox as true or not.If is true then we need to show the action. This attachment action so when we create attachment action, action model fields comes automatically where attachmentSysId is there. 
 

In script condition,current.sys_id takes incident sys_id where attachment is attached.

In client conditions ,it shows action model fields which has attachmentSysId but it does not accept scripted filter in it. For e.g. attachmentSysID "Is one of" javascript:new global.checkAttachment().checkAttachment(current.sys_id).
I need to add criteria or condition on action so that it will check for each attachment if the checkbox is true in the attachment or not.

@pratikshabh 

what do you mean by attachment record?

based on which record's field you need to hide that?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

pratikshabh
Tera Contributor

Hi @Ankur Bawiskar Any idea or thoughts ?