Copy link to clipboard
Copied
Good Afternoon,
I have created a form in Acroabt PRO DC, in it I have a field with 2 javascript in, the first one is to make sure that all the fields are filled and the second one is to attach a document to the form.
What happens now is, if I didn´t filled all the fields, appears a pop up alert with the info of witch fields are missing but the problem is that the 2nd code will run anyway, even if the they filled the fields or not, what I need is that the 2nd code (attach document) run only when the fields are all filled.
Then use this code:
if (Ex2ValidFields()) {
try {
var annot = this.addAnnot({
page: 0,
type: "FileAttachment",
point: [500, 500],
noView: true,
author: "Attachment"
});
annot.cAttachmentPath;
var attachmentObj = annot.attachment;
if (attachmentObj !== null) {
app.alert("file successfully added: " + attachmentObj.name,3, 0, "Pedido de Investimento");
var l = this.getField("lst1");
l.insertItemAt(attachmentObj.name, 2);
}
}
catch(e) {
if (e.name ==
...
Copy link to clipboard
Copied
Combine the JavaScript into one, and only run the attach part of it is applicable.
Copy link to clipboard
Copied
And How can I do this? the codes are:
1rst one:
try {
var annot = this.addAnnot({
page: 0,
type: "FileAttachment",
point: [500, 500],
noView: true,
author: "Attachment"
});
annot.cAttachmentPath;
var attachmentObj = annot.attachment;
if (attachmentObj !== null) {
app.alert("file successfully added: " + attachmentObj.name,3, 0, "Pedido de Investimento");
var l = this.getField("lst1");
l.insertItemAt(attachmentObj.name, 2);
}
}
catch(e) {
if (e.name == "NotAllowedError") {
// do nothing
}
}
and 2nd
javascript is call -»
{
(Ex2ValidFields())
}
I have tried like to put first the 2nd code and after the 1rs one mas the document still run the attached document even with blank fields
Copy link to clipboard
Copied
Ex2ValidFields is your code, it is a function somewhere in the document or user JavaScripts. You have to find it, understand it, and work with it to give a success/failure code to test.
Copy link to clipboard
Copied
I know where my code is 🙂 is in my javascript document
Copy link to clipboard
Copied
if you open the console, do you get any errors? Seems like you're missing a condition to handle that part.
Maybe you also need to re-verify where are you trying to run the event from: is it a custom calculating script? a mouse-up event button? a custom keystroke script? a custom format script? a custom validating script?
As Test Screen Name mentioned, you have a function thatis called from one of those fields.
You need to elaborate a condition to do something or do nothing when fields are empty and when fields are filled in, and then call that function only when such condition(s) are met.
Copy link to clipboard
Copied
Hi, tx a lot for your reply, so... the 1rs code is in my javascript document:
and I have created a button with mouse up event and put 3 javascript code in it, the 1rs one calls my function "Ex2ValidFields" and allow to attach documents, am I doing wrong? there is a better way to do it?
Copy link to clipboard
Copied
Does the function Ex2ValidFields return a value?
Copy link to clipboard
Copied
Hi, yes this code valid if all the fileds are filled and show a pop up message alert with the name of the fields that need to be filled
Copy link to clipboard
Copied
Showing an alert is not the same as returning a value...
Copy link to clipboard
Copied
right..sorry, very low experience
Copy link to clipboard
Copied
It will be easier to help you if we could see the full code, or the actual file itself...
I see you have a variable in this function called bRtn. I'm guessing this is what holds the return value.
If that's the case then you can use it like this:
if (Ex2ValidFields()) {
// put code to attach document to the file here
}
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Do you want all of the actions under that button to be dependent on the return value of Ex2ValidFields, or just the one that attaches a document to it?
Copy link to clipboard
Copied
yes I need all of the actions under that Button
Copy link to clipboard
Copied
Then use this code:
if (Ex2ValidFields()) {
try {
var annot = this.addAnnot({
page: 0,
type: "FileAttachment",
point: [500, 500],
noView: true,
author: "Attachment"
});
annot.cAttachmentPath;
var attachmentObj = annot.attachment;
if (attachmentObj !== null) {
app.alert("file successfully added: " + attachmentObj.name,3, 0, "Pedido de Investimento");
var l = this.getField("lst1");
l.insertItemAt(attachmentObj.name, 2);
}
}
catch(e) {
if (e.name == "NotAllowedError") {
// do nothing
}
}
this.getField("Validacaochefia-direcao").display = display.visible;
this.getField("NOKDIRECAO").display = display.visible;
this.getField("Direcao").display = display.visible;
this.getField("ObsDIRECAO").display = display.visible;
this.mailDoc({
cTo: "marlene.marques@kirchhoff-automotive.com",
cCc: "bernardo.brandao@kirchhoff-automotive.com",
cSubject: "Pedido de Investimento - VALIDAÇÃO",
cMsg: "Cara Marlene,\n\nEm anexo envio o Pedido de Investimento devidamente preenchido, por favor validar se a informação está conforme o exigido, para mais informações, disponha.\n\nObrigado."
});
}
Copy link to clipboard
Copied
it work perfectly! thanks a lot
Copy link to clipboard
Copied
Hi try 67, Regarding the below code, everything work perfectly but the action of sending the email doesn´t, it stop after attach the email, can you please help me?
Copy link to clipboard
Copied
That's how it is supposed to work. The user has to send the email manually. Doing so automatically requires installing a script on the local machine of each user.
Copy link to clipboard
Copied
So if I want to have a code that doesn´t allow the useres to attach files without filled out all the fields I cannot have in a automatic way the code to send the email, this is it?
Copy link to clipboard
Copied
Unless you can install a script on their machines, no.
Copy link to clipboard
Copied
Can anyone help me with this script?
\\ TAMPLATE FILL IMAGE //
1) Select the layer
2) Selected layer name change
3) Select multiple image Drive path
4) Open image >Copy>Close>First Select layer>Paste>Convert smart Object>Create clpping mask> fit to frame>Select layer name change
**Similarly selected layers will be filled
Copy link to clipboard
Copied
SUBIR23858377qxke, that's not really a script, it's a request for someone to write one for you. I have to say, it doesn't sound like anything that can be done in Acrobat JavaScript. I wonder if you really wanted a different forum?
Copy link to clipboard
Copied
I want a script just like the one I wanted
Copy link to clipboard
Copied
Ok, SUBIR23858377qxke, exactly what Adobe application do you need the script for?
And exactly what version of the Adobe application (not "latest" please, but the actual numbers)?