Can someone with more ATF experience help me with this?

paulomafra
Kilo Expert

 

I need to submit a Catalog Item during a test, but there is a mandatory attachment field. 

 

The issue is that when using "Set Variable Values" the input appears as a String/Single Line Text field, so I can't mock a generic image (for example) which would be sufficient, since the field itself isn't the focus of the test, just a requirement for submission. 

 

Even using a "File Attachment" parameter doesn't seem to work. Does anyone know a workaround for this to submit the form via ATF?

 

It is worth mentioning that I have already tried using a sys_attachment sys_id in this input. I also tried using a different "Add Attachments" test step, but it only works for that OOB field at the bottom of the form, not for custom variables.

1 ACCEPTED SOLUTION

paulomafra
Kilo Expert

The solution that worked for me was using the sys_id of a sys_attachment record directly in the string input generated by the attachment field, as suggested.

 

However, the important detail is that the "Table name" column is empty; presumably, if the test were performed by a user with access to that specific table or an admin role, this wouldn't be an issue.

 

Thank you all for the help!

View solution in original post

9 REPLIES 9

Rafael Batistot
Mega Patron

Hi @paulomafra 

 

Get the ⁠sys_id⁠ of any valid attachment from the ⁠sys_attachment⁠ table.

 

In the Set Variable Values step, pass that ⁠sys_id⁠ into your attachment variable. The form will accept it as a valid uploaded file.

 

https://www.servicenow.com/community/developer-forum/how-to-upload-files-into-catalog-item-variables...

 

Unfortunately, it still hasn't solved my problem—even after querying `sys_attachment` for a valid record and adding that ID to the input. I also can't use that return value with a dynamic parameter.

paulomafra_0-1786891707229.png

 

paulomafra_1-1786891710376.png

The result is the same as mocking a sys_id directly in the input without a prior query: Invalid value.

paulomafra_2-1786891800196.pngpaulomafra_3-1786891813453.png

 

 

Ankur Bawiskar
Tera Patron

@paulomafra 

did you check this?

Adding attachment to record producer in ATF 

💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏

Ankur Bawiskar
Tera Patron

@paulomafra 

it did work for me

Steps: I gave sysId of any 1 sys_attachment record as input

AnkurBawiskar_2-1786761474769.png

 

AnkurBawiskar_1-1786761443157.png

AnkurBawiskar_3-1786761501768.png

 

Output: File attached to variable

AnkurBawiskar_0-1786761379687.png

 

💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏