Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

Custom file name to save the pdf using a button


Level 3



We can save a file where user need to give a file name





Now, I want a button, if user click then it will suggest user a pdf name based on the value given in the form. 

I am using the below code (based on this post) [on the button for click action]


var mySaveAs = app.trustedFunction(
   function(oDoc, cFlName) {
      try {
      } catch (e) {
         app.alert("Error During Save");


// Append the suffix "review" to the file name
var suggestedFileName = xfa.resolveNode("Num").rawValue + "_review";

mySaveAs(event.target, suggestedFileName + ".pdf");



But getting an error  


NotAllowedError: Security settings prevent access to this property or method.



Here, I used the trusted function's begin, and end privatization. But still why I am getting error, and how can I solve the error?


Update: I think I need to put the trusted function in my Adobe's JavaScript folder. However, this doesn't seems to be the best practice for my purpose, as I can't control my user's machine (and can't put the JS file on the Folder Level). Are there any other options to achieve the "Rename" functionality?


Thank you 


Topics help categorize Community content and increase your ability to discover relevant content.

0 Replies