Expand my Community achievements bar.

Saving silently when signing problems

Avatar

Level 2

Hi everyone!

I've tried to use my "saving file remotely with predetermined name format" scripting code (it was in a button:click_event, with trusted function and working ok) in the signature filed change event, in order to save the document silently whenever it is signed, but something is wrong there.

When I sign the document, the script runs but It shows me the "It was not possible to save the document" message. The weird thing is that whenever I clear the signature, it makes the copy correctly !!

I think I know how the CHANGE EVENT works, but I can not understand why is not working when signing but working ok when you clear the signature!

The code is:

----- topmostSubform.Page1.SignatureField1::change: - (JavaScript, client) ----------------------------

// Ensuring the function is trusted in config.js

if(typeof(mySaveAs) == "function") {

mySaveAs(event.target

,"/c/carpeta", "CE10090-0103" + "_" + xfa.form.topmostSubform.Page1.OF.rawValue + "_Op-130_1.pdf");

}

else {

app.alert("Missing Save Function\n"

+

"Please contact forms administrator");

----------- CONFIG.JS ------------------------------------------------------------

// función en nivel restringido
var mySaveAs = app.trustedFunction(
function(oMyDoc,cMyPath,cMyFlName)
{
var bSucess; // value for return
// some debugging statements
console.println('oMyDoc: ' + oMyDoc); // object for debuggingg
console.println('cMyPath:' + cMyPath); // path for debugging
console.println('cMyFlName: ' + cMyFlName); // new file name for debugging

// Ensure path has trailing "/"
cMyPath = cMyPath.replace(/([^/])$/, "$1/");
app.beginPriv();
try{
   // path and file name & extension for debugging
  console.println('cMyPath + cMyFlName:' + (cMyPath + cMyFlName)); // debugging
  oMyDoc.saveAs({cPath:cMyPath+cMyFlName, bCopy:true, bPromptToOverwrite:true});
  bSuccess = true; //set return value
}catch(e){
  bSuccess = false; // set return value
  app.alert("It was not possible to save the document");
}
app.endPriv();
return bSuccess; // return status of action
});
// end of application folder function

0 Replies