Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

PDFGenerationAPI: How to place attachment ONLY in a file_attachment field instead of header

Joe Walters
Tera Guru

I'm using the PDFGenerationAPI in a UI Action to generate a PDF and attach it to a specific document and, as expected by default, it's visible the form header.

 

I also have a 'file attachment' field, however, and this is where I actually want it to appear (and only there).

 

Anyone know of a way to only show the attachment in the file attachment field and not also in the form header?

 

JoeWalters_4-1701975350427.png

 

 

 

 

6 REPLIES 6

Yeah, I'd prefer no DOM manipulation. ServiceNow is doing it within the platform somehow, but I don't understand exactly how, or I'd replicate it.

Joe Walters
Tera Guru

So, I got a closer, but almost feel further away now.

 

As mentioned before, in the global scope I'm able to use the code above to create a PDF and attach it to a record (e.g on the Incident table). I'm then able to get the sys_id of the newly created attachment and put it in my file attachment field.

 

If I then prepend the sys_attachment record's table_name field with ZZ_YY (e.g. change it from incident to ZZ_YYincident), the attachment will no longer appear in the header of the form, but remains visible in the file attachment field. This is exactly what I want to happen.

 

The problem now is that I don't see a way to do the same in a custom scoped app (the sys_attachment table's cross-scope access policy prevents it and I don't think the customer would be willing to change it).

 

Still searching for a solution and open to ideas. 😕