Hi Paul,
I'm reading your post and your answers, but somehow i cant do it. I've downloaded Lock All Fields - not buttons_Purchase Order.pdf and copied your script (myScriptObject.LockAllFields(form1);) to my regular button. It doesn't work....What im doing wrong?..missing something?..I have to say that im lowler then novice....
Can you help me plese?
Can you send the form and a description of th eissue to LiveCycle8@gmail.com and I will have a look when i get a chance.
paul
Hi,
One thing that may have happened is that you only copied the button into your form.
The button has the following script:
myScriptObject.LockAllFields(form1);
This line calls a function named 'LockAllFields'. This is not a built-in function, it is a custom script written by Paul and it is stored in a script object, called 'myScriptObject'.
The syntax in the click event of the button is the full reference to the function: [name of script object].[name of function](parameter);
If you look at the hierarchy, you can see the 'myScriptObject' in the Variables, under the purchaseOrder page.
If you select the script object you can look at the function in the script editor.
The sequence is:
So all the action is happening in the script object and not really in the button at all.
So for your form you will need to copy 'myScriptObject' as well as the button.
Hope that helps,
Niall
Hi Niall,
Thank you for your answer. Now I understand what I'm missing, but still dont know how to add "myScriptObject" in the Hierarchy palette on the left. I'm sorry but i dont have any experiance in scripting.
I created a form with couple of text fields and drop down lists. Also, i have 4 buttons included (Lock_button, SaveAs_button, Reset_Button and Submit_button with costum script you wrote for me) .
Here is my scenario:
When user open the form he/she sees only Lock_button and Reset_button. When they fill the form and hit lock button the form fields are locked and the Lock_button desappears. Desappering of the Lock_button triggers SaveAs_button to become visible. When they finish saving non fillable pdf the SaveAs_button desappears and that triggers Submit_button to become visible. Now they hit submit button which opens outlook with costum script. Reset Button is visible all the time.
I'm stacked with Lock_button and with setting visability of the buttons. Feal like Grimsby playing in premier league.......
https://acrobat.com/#d=uLq7FOEliO*MHLOWFrvDZg
Help please
It works now. I figured out where i had to place the function script.
Can you help me with visability?
thanks
Message was edited by: Mar.ko
By heck, ![]()
Here is the form back to you: https://acrobat.com/#d=*jSHIzy-zFVL-QNo6KCQ1Q
There are a couple of ways you can do this.
This is probably the easiest:
Step 1: Right-click on 'page1' and click 'Insert Script Object'. This will insert a blank script object, which is unnamed.
Step 2: Name the script object. In this case you want to match Paul's script object name: 'myScriptObject'.
Step 3: Open Paul's form and copy ALL of the script from his script object.
Step 4: Go back to your form and paste the script into your script object.
Step 5: Test - any problems open the Javascript Console (Control+J) and see if there are any errors showing up.
The other option is to open Paul's form and drag the script object into the Fragment library (next to the Object Library). Then open your form and drag the fragment onto 'page1'. This will insert the script object as a fragment. Right-click on it and from the fragment menu convert the fragment to an object. Test, test, test...
In relation to the buttons, I have script in the lock all fields button AFTER the function is called to hide the lock button and the reset button. The save as button is then made visible. This is possible by accessing the .presence property.
A similar approach is used on the saveAs button, however this is tricker. At the moment I have the script in the click event of the saveAs button, however if the user cancels the save action, the buttons presences still change. So I have used Radzmar's solution to check if the form is dirty.
A couple of things:
I hope this helps,
Niall
Hi Niall,
Me again....
I've tested the form and noticed that I need to have reset button after my users send me the file. So they should be able to start filling the form again immediatly after they finished with previous one.
I added this line of code( Button5.presence = "visible") in click event of the submit button. It works, but it should unlock the form so they can start using the form again! How can I achive that?
Thank you for helping me
Marko
Hi,
This is an excellent opportunity to look at the function in detail.
Basically you need to create a similar function to unlock all the fields. This is very straightforward.
First go into the 'myScriptObject' and copy all of Paul's function. Then go below his function and paste. You now have two separate functions in the one script object, this is perfectly normal - you just need to rename the new one:
/*************************************************************************************
Function: UnLockAllFields
Description: This function will unlock all fields.
IN: The parent subform. It could also be an element that contains subform like form1
OUT : nothing
**************************************************************************************/
function UnLockAllFields(myParentObject){
var allChildElements;
...
See how I have called it 'UnLockAllFields'.
Now you need to edit this new function. Paul has two lines that set the access of the currentElement to 'readOnly'. You need to change this in your new function to 'open' (in just two locations):
currentElement.access = "open";
The last step is to call the function in your 'reset' button. I would put this line at the start of the script:
myScriptObject.UnLockAllFields(form1);
Should work - good luck,
Niall
Hi Niall,
I've copied/pasted/renamed Paul's function just like you said, but it doesnt work. In the reset button i already have script (again written by you of course
) and that works but the form stays unfillable. I also tried to place "myScriptObject.UnLockAllFields(form1);" before it and after it as well. When i tested, it doesn't work.
here is the file with last modications:
https://acrobat.com/#d=tp-spETA1mR9w*VzMpJXig
Marko
Hi Marko,
Here is the form back: https://acrobat.com/#d=garF1g40Y2T-s294LxnVOg
There was a line that I neglected to highlight to you.
if(allChildElements.item(j).className == "subform"){
UnLockAllFields(currentElement);
}
Basically this is testing if the currentElement is a subform AND if it is, the script reruns the function, this time passing the subform in as the parameter. This basically ensures that all objects are locked, no matter how deep they are buried in nested subforms.
That should get you out of the blocks,
Niall
Hello Paul,
I used your script. But my need is if the user submits the form by clicking the button (which submits the pdf in an email) then : The email receiver when opens the form it should be readonly. But in my case it's editable. I am using LiveCycle Designer 8.2 and Acrobat 9 pro. The target version is : Acrobat or Adobe reader 8.1 or later.How to get it over with ?
Thanks.
Bibhu.
Is the script being run before you email it? If so then you are not saving teh state of the form. In the File/Form Properties/Defaults tab make sure that the Radio button that controls the "Preserve Scripting Changes...." is set to Automatically. If you are asking where the script should be executed ...you can add teh call to to the preSubmit event of the button.
Paul
Then that prooves that either they are not included in the subform that is being passed to the Locking code .....or the code has been modified to ignore those fields. I cannot tell specifically without seeing your form. Can you share it with me? If so send it to LiveCycle8@gmail.com and include a description of the issue.
Paul
Hey Paul,
First off thanks for providing this script for everybody! You truly are a life saver!!!
Second, okay i got your script to work as a button, but what I would like is a tad different.
Would it be possible for me to have the script run once I click "file">"save as" and then the person who typed the quote in this case would name the file what they want, save it and then the original file would become unlocked while the newly saved file will be locked?
EDIT: ^^^^^^Scratch that part of my message, it was easy enough to set the code to lock it once i save it from clicking "file">"save as"....and obviously the original file is not locked.
The problem im having is there are times where we will send out a quote to a customer, and then we will need to make a provision to the quote upon the customers request. So is it possible to unlock the PDF after it is locked so that we can make adjustments and not have to re-type everything?
What would be perfect is if i could have two buttons at the end of my PDF file. One would be to save for our copy that can be edited later on, and the Second would be to save the file with all fields locked.
Please enlighten me if this is even possible.
Thanks for any help!
Message was edited by: HKSevo8 Part of message was unnecessary, which is the quoted part :) Note: Refer to txt below commented part of post.
Okay i think that i solved my problem, but i came up with yet another issue "/
Okay i made one button as a test that says "Save Un-Locked" that I have the javascript under click to be
app.execMenuItem("SaveAs");
And then i made a second button that says "Save Locked" that I have the javascript under click to be:
app.execMenuItem("SaveAs");
myScriptObject.LockAllFields(form1);
The issue that I am coming up with is once i click the first "Save Un-Locked" button, the "save as" dialog pops up, i save the file, and then the same dialog pops up again so i click either save once again or cancel....then the following error pops up:
Even though i get that error message, the buttons seem to be working. When I click Save unlocked, a copy is saved that can be editied later. When I click save locked, all fields become locked for the newly saved PDF.
Any ideas? It is possible to have two save as buttons correct?
Thanks
Thanks for the reply Paul,
Yea I thought the same after reading that error, but thats not the case. I triple checked to make sure the language for both buttons under "click" was set to javascript. I even set the "All Events" section to javascript.
Any other ideas?
Thank again for the help!
Solved my own problem again lol, ![]()
IDK why I was getting the errors, but i decided to just delete the damn things and start over. After re-making the two buttons, they both work like a charm!!
Did nothing different from the first two buttons. Weried hahaha![]()
As long as they work, thats all I care about haahaha
I think I have one last quesiton though.
Is there a way to save the PDF that will have all locked fields, without those two buttons showing up? I would perfer that our customers not see the save as buttons ya know?
Thanks
North America
Europe, Middle East and Africa
Asia Pacific