Hello,
I've been working on a multiple-item quote request form. My intention is that Party A (Requestor) will fill in the item description and details necessary for Party B (Vendor) to provide a quote. The form will be emailed to the Vendor who will complete the remaining fields (price and delivery) and email the form back to the Requestor.
The item description and details (provided by Requestor) and the item price and delivery (provided by Vendor) are both wrapped in thier own subform and both are contained in a repeating subform. I've scripted the buttons that add/delete instances of the subform for each separate item being quoted and the button that emails the form to the Vendor. It took me a long time, but I finally got the buttons to work!
Now I'd like to find a way to 'lock' the fields filled by the Requestor when the form is emailed but still leave the fields open that need to be completed by Vendor. I'd also like to lock the contact information fields at the top at the same time. I've attached a JPEG with the form layout to clarify...
I've been reading a lot of old posts regarding similar topics and tried some of the solutions provided but cannot seem to make them work for my application. The closest I've been able to come is locking the entire form. I have the form set to email on event=click of the "Submit to Vendor via Email" button and the locking action on the event=mouseup of the same button.
Does anyone know how I should approach this? I'm begining to think I designed my form and myself into a corner! Unfortunately I do not have a server on which to host the form but would be happy to email it to anyone willing to help.
Thanks,
Jake
Views
Replies
Total Likes
Hi Jake,
Paul has an excellent solution here: Re: Locking selected fields of a fillable form
You need to copy the script object 'myScriptObject' into your form, because this is where the main action takes place.
Also the script in Paul's 'lock all fields' button call the function 'LockAllFields' in the script object.
myScriptObject.LockAllFields(form1);
You see that Paul is passing the name of the root node 'form1' through to the function. This means that all objects in the form are locked.
You would need to set up separate email buttons, with the above script before the email script. Instead of passing 'form1' through to the function you would pass the name of the subform that you want to lock.
If you do a search of 'lock all fields paul' on the forum, you will get other discussions of this solution.
Hope that helps,
Niall
Views
Replies
Total Likes
Niall,
Thank you for the help. I've been playing a with Paul's script a little bit but still having some difficulty. I know the problems are due to my inexperience with scripting, but I'll get it sorted out.
I have one additional question though. The subform I want to lock is contained inside of a repeating subform. If I pass the name of the subform I want to lock in Paul's script, will all instances of that subform be locked? I just don't want to spend all the time to figure it out if it's not the right way to go!
Thanks,
Jake Zachry | Western Area Support Engineer
Baker Hughes | Operations/Western Area/Baker Oil Tools
Office: +1 805.644.5541 | Fax: +1 805.644.8771
Cell: +1 805.256.5401 | jacob.zachry@bakerhughes.com
http://www.bakerhughes.com | Advancing Reservoir Performance
Views
Replies
Total Likes
Hi Jake,
Here is a sample where the 'Subform2' is repeatable. https://acrobat.com/#d=a9ZE9MPvgEVYjsiIwbU47Q
I have amended it to lock the repeating subform. Basically you need to set up a loop to work trough each repeated instance of the subform and lock each one in turn.
var j = _Subform2.count;
for (var i=0; i<j; i++)
{
var currentSubform = xfa.resolveNode("Subform2[" + i + "]");
myScriptObject.LockAllFields(currentSubform);
}
Stick with it, I think you are on the right track with Pauls' script.
Niall
Views
Replies
Total Likes
Ok. I got the lock feature to work...kind of. I can get it to lock the fields desired subform (bhiinput) but it only works on the first instance and will not lock any subsequent instances.
My repeating subform, Subform1, is not allowed to break between pages. The first instance of Subform1 is on the first page, but any additional instances of Subform1 are placed on the next page. Could this be part of the problem?
I attached screen shots of the lock button script and myScriptObject in the current configuration
The myScriptObject jpg is hard to see, but I didn't change anything from the example you provided previously.
Views
Replies
Total Likes
Hi Jake,
The script in the click event is nearly there.
You are correctly resolving the repeating instance of Subform1; however you are not passing this through to the function.
When you call the function you are only passing through the first instance of the subform. In addition you are tagging on 'bhiinput'. This is why it only works for the first instance.
In the loop you would need to fully resolve the subform that you want and then pass this through to the function.
var j = _Subform1.count;
for (var i=0; i<j; i++)
{
var currentSubform = xfa.resolveNode("Subform1[" + i + "].bhiinput");
myScriptObject.LockAllFields(currentSubform);
}
See how you tag on the desired subform inside the repeating subform when resolving the node.
Fingers crossed this should work!!
Niall
Views
Replies
Total Likes
Hi Niall,
I have been trying to work this script into my form and I am having the opposite problem as bakerjake where all instances lock. Currently I am using the AD modified script with "lock" and "unlock" functions, attempting to lock the current instances of full page subform (TRANSMITTAL). As it stands now, all instances lock/unlock using the below code:
Please advise.
Views
Replies
Total Likes
Hi,
That is what I would expect. The for loop is working through each instance of TRANSMITTAL and passing it to the function (LockAllFields) in the script object (varLOCK). Everything (except buttons) in all instances of TRANSMITTAL will be locked.
Objects outside of TRANSMITTAL should remain open.
Are you trying to lock only the last instance of TRANSMITTAL?
Niall
Views
Replies
Total Likes
I dont know what I was thinking. After some rest, and a second look, I can see this what the code is doing.
I am trying to provide a button that will lock elements on individual pages that are part of multiple instances. Note, each instance will contain said button.
Example: TRANSMITTAL[3].lockButton should only lock items on that instance of TRANSMITTAL[3].
The two attempts had different results
form1.TRANSMITTAL.lockButton::click - (JavaScript, client)
var j = _TRANSMITTAL.count;
for (var i=0; i<j; i++){
var currentSubform = xfa.resolveNode("TRANSMITTAL[" + i + "]");
varLOCK.LockAllFields(currentSubform, "Lock");
}
..resulted in Locking ALL instances.
form1.TRANSMITTAL.lockButton::click - (JavaScript, client)
varLOCK.LockAllFields(form1.TRANSMITTAL);
..resulted in nothing.
Any suggestions?
Views
Replies
Total Likes
Hi,
A couple of things:
If the function is expecting two parameters, then you will have to pass two parameters when calling the function. There are a couple of versions of this solution around, some with the "Lock" parameter. Just make sure you are using the correct one.
Instead of looping though the instances, just reference the parent of the button:
varLock.LockAllFields(this.parent, "Lock");
If the button is inside a subform, inside of the TRANSMITTAL subform, then it would become this.parent.parent.
Hope that helps,
Niall
Views
Replies
Total Likes
Thanks, that code worked perfectly. I also implemented the loop code on a separate function to HIDE all the Transmittals.
How would I implement this.parent concept into assigning rawValues to specific objects without the affecting the same element in every instance?
EDIT: Answered my own question:
xfa.resolveNode("TRANSMITTAL[" + this.parent.instanceIndex + "]").txtTransmittalType.rawValue = this.rawValue;
Views
Replies
Total Likes
Hi Niall,
I've got a similar issue with an Livecycle extended features form which has repeating instances within.
I have followed the below coding to lock individual instances, allowing users to lock information and then at a later date, add more.
{
form1.(name).lockButton::click - (JavaScript, client)
var j = _(name).count;
for (var i=0; i<j; i++){
var currentSubform = xfa.resolveNode("(name)[" + i + "]");
varLOCK.LockAllFields(this.parent, "Lock");
}
That part works fine while the user is in the form, adding and locking to hearts delight.
However when it is saved (using file--> Save As)and then reopened, the locked fields are now unlocked and can be modified. It'd be preferable for locked fields to be remain permanently locked.
About the form: I can't add electronic sig. fields (agency isn't there yet) nor database; this form sits on a shared drive, allowing those with shared drive access the ability to open and add to the form; printing out a hardcopy yearly.
What am I missing to enable to locked fields to remain locked after reopening? My coding skills are low; for the most part I've been following or amending recipes I find.
Many thanks.
Views
Replies
Total Likes
Hi,
I don't know why you haven't provided the name of the repeating object, but I'll go on the basis that the code is working.
If you go to File > Form Properties > Defaults, make sure that Preserve Script Changes is set to Automatic.
Hope that helps,
Niall
Views
Replies
Total Likes
Success works like a charm.
Thanks Niall, I would have never known to look there.
Views
Replies
Total Likes
Views
Likes
Replies