Copy link to clipboard
Copied
I have a form that asks whether an item was budgeted and then the price of the item. This form is to be emailed to certain people based on whether the item was budgeted and also the price. I have buttons set up that runs the script of who to email the form to when clicked on. I want to be able to have a button called 'Submit to COO' appear if the item was not budgeted, or if the item was budgeted but the price is $50,000 or more. If this is not the case, then I want a button called 'Submit to CFO' if the item was budgeted and the price is under $50,000. Is this possible to do? If so, please provide the steps on how to make it work.
Thanks.
Copy link to clipboard
Copied
assuming acrobat...
in the future, to find the best place to post your message, use the list here, https://community.adobe.com/
p.s. i don't think the adobe website, and forums in particular, are easy to navigate, so don't spend a lot of time searching that forum list. do your best and we'll move the post (like this one has already been moved) if it helps you get responses.
<"moved from using the community">
Copy link to clipboard
Copied
Yes, I have Adobe acrobat.
Copy link to clipboard
Copied
good. your post is in the acrobat forum.
Copy link to clipboard
Copied
Is this a check-box, a drop-down field, a text field, or something else?
Copy link to clipboard
Copied
The yes or no response for a budgeted item are radio buttons, the price is a text field and the 'Submit to COO' and 'Submit to CFO' are buttons.
Copy link to clipboard
Copied
This is the JavaScript I currently have. It works correctly when the item was not budgeted. However, I can't get it to work correctly when the item was budgeted and the price was less than $50,000.00 or when the item was budgeted and the price was more than $50,000.00. What am I doing wrong?
var Q=this.getField("Budgeted?");
var R=this.getField ("ActutalBudget");
var A=this.getField("Submit to CFO");
var B=this.getField("Submit to COO");
if(Q.value==="Yes" && R.value<"50,000.00"){
A.hidden=false;
B.hidden=true;
}
if(Q.value==="YES" && R.value>="50,000.00"){
A.hidden=true;
B.hidden=false;
}
if(Q.value==="No"){
A.hidden=true;
B.hidden=false;
}
Copy link to clipboard
Copied
Couple of notes:
- Don't use the hidden property. It was replaced by the display property.
So replace these lines:
A.hidden=false;
B.hidden=true;
with:
A.display = display.visible;
B.display = display.hidden;
- When comparing to a number you must not put it in quotes, or it will be treated as a string.
So change this part of the code:
R.value<"50,000.00"
With this:
R.value<50000.00
- JS is case-sensitive, so "Yes" and "YES" are not the same thing.
- You need to add a condition to your code that deals with the case when neither Yes or No are selected. In that case, the value of the check-box group will be "Off" by default.
Copy link to clipboard
Copied
I have made the changes as you mentioned. I tried to add in the condition when neither Yes or No are selected but it's not working. Here is what I put:
var Q=this.getField("Budgeted?");
var R=this.getField ("ActutalBudget");
var A=this.getField("Submit to CFO");
var B=this.getField("Submit to COO");
if(Q.value!=="Off");
if(Q.value==="Yes" && R.value<50000.00){
A.display=display.visible;
B.display=display.hidden;
}
if(Q.value==="Yes" && R.value>=50000.00){
A.display=display.hidden;
B.display=display.visible;
}
if(Q.value==="No"){
A.display=display.hidden;
B.display=display.visible;
}
What did I do wrong? Sorry, learning as I go with the conditional formatting.
Copy link to clipboard
Copied
Try this code:
if (Q.valueAsString == "Yes") {
if (Number(R.valueAsString) < 50000.00) {
A.display = display.visible;
B.display = display.hidden;
} else {
A.display = display.hidden;
B.display = display.visible;
}
} else if (Q.valueAsString == "No") {
A.display = display.hidden;
B.display = display.visible;
} else {
A.display = display.hidden;
B.display = display.hidden;
}
If it still doesn't work you'll need to share the file for further help.
Copy link to clipboard
Copied
It doesn't seem to be working correctly still. I have shared the file. I seem to be having issues with the last three approvals. The approval flow is the following:
- If it is an approved budget item and less than $50,000.00 it should be submitted to the CFO for the final approval.
- If it is an approved budget item but equal to or more than $50,000.00 it should be submitted to the COO for approval and then to the CFO for the final approval.
- If it is not an approved budget item it should be submitted to the COO for approval and then to the CFO for the final approval.
I was also working on the show/hide fields. I don't want the COO approval section to show up until it is determined that the COO needs to approve. Same with the CFO section, I don't want it to show up until it is determined that the CFO needs to sign.
Copy link to clipboard
Copied
Just following up to see if you have been able to get this working correctly. I have been trying different things and it's like I get one thing to work but then something else doesn't. Any help is greatly appreciated. Thanks.
Copy link to clipboard
Copied
Try this as custom calculation script of any text field:
var Q=this.getField("Budgeted?").valueAsString;
var R=Number(this.getField("ActutalBudget").valueAsString);
var A=this.getField("Submit to CFO");
var B=this.getField("Submit to COO");
A.display = (Q !== "Off" && (R > 0 && R < 50000)) ? display.visible : display.hidden;
B.display = (Q === "Off" || (Q === "Yes" && R >= 50000)) ? display.visible : display.hidden;
Copy link to clipboard
Copied
Thanks Nesa, I have been able to get the form to work correctly using your formula, except for the last section. My last section is the final signature by the CFO. I want it to be hidden until the submit to CFO decision has been made by R>0 && R<50000 or it has gone to the COO and the submit to CFO button appears under that signature. I have been trying to adjust the script above for it, but can't get it to appear at the correct time. Are you able to provide the script so that it appears at the correct time?
Here is the last script I tried where it is hidden, but doesn't appear in either case:
var Q=this.getField("Budgeted?").valueAsString;
var R=this.getField ("Submit to CFO").valueAsString;
var S=this.getField ("submit to CFO3").valueAsString;
var A=this.getField("CFO-HIDE");
var B=this.getField("CFO");
var C=this.getField("Approved");
A.display=(Q =="Yes" && R.display==display.visible ||Q=="No")? display.visible:display.hidden;
B.display=(Q =="Yes" && R.display==display.visible ||Q=="No")? display.visible:display.hidden;
C.display=(Q =="Yes" && R.display==display.visible ||Q=="No")? display.visible:display.hidden;
Copy link to clipboard
Copied
What is the point of "S" variable since you don't use it?
If "Budgeted?" is checkbox first of all when checkbox is not checked its value is "Off" not "No", also why you use "Yes" and "No" in same condition? This doesn't make much sense, can you explain what conditions should be?
Copy link to clipboard
Copied
I put "S" because I was going to try and build something in for when the 'Submit to CFO' button appears below the COO signature. The selection options for Q is yes or no, which is why I have both in the same condition. The conditions should be:
- If neither Yes or No are selected for Q, I would like the CFO-HIDE, CFO and Approved buttons to be hidden.
- If Q is Yes and the Submit to CFO button is visible, I would like the CFO-HIDE, CFO and Approved buttons to be visible.
If Q is no and the Submit to CFO3 button is visible, I would like the CFO-HIDE, CFO and Approved buttons to be visible.
Copy link to clipboard
Copied
In your script you used "submit to CFO3" in the text you wrote its 'Submit to CFO3', JavaScript is case-sensitive so you need to pay attention to that.
From what you wrote, if I understood correctly your conditions, try this script:
var Q=this.getField("Budgeted?").valueAsString;
var R=this.getField ("Submit to CFO");
var S=this.getField ("Submit to CFO3");
var A=this.getField("CFO-HIDE");
var B=this.getField("CFO");
var C=this.getField("Approved");
if((Q == "Yes" || Q == "No") && (R.display == display.visible || S.display == display.visible)){
A.display = display.visible;
B.display = display.visible;
C.display = display.visible;}
else{
A.display = display.hidden;
B.display = display.hidden;
C.display = display.hidden;}