What I am looking to do is to copy a field and when a new instance of a subform is created past it to another field.
When a user clicks the transmit button, the transmit button opens a new instance of the form. I need the Sent To field to populate the Reviewer field on the new instance. Is this a possibility?
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
Here is an example:
https://acrobat.com/#d=HD6XJ1qofZDf713Yq1P43g
The first example just sets the value of the dropdown. The second adds an item to the Reviewer dropdown, as the Send to dropdown allows custom entry.
I'm been lazy though as the script should check for duplicates first. I'll try and get back to this.
Hope that helps,
Niall
Views
Replies
Total Likes
Hi,
When you say another instance of the form, do you mean a new instance of the subform within the XFA form?
If this is the case then yes it is possible with a bit of scripting.
You would basically need to count the number of instances and then resolve the nodes for the objects in the two instances.
// script to add instance of subform
// count the number of instances zero based numbering
var lastRow = _mySubform.count - 1;
var 2ndLastRow = lastRow - 1;
xfa.resolveNode("mySubform[" + lastRow + "]").reviewer.rawValue = xfa.resolveNode("mySubform[" + 2ndLastRow + "]").sentTo.rawValue;
You will need to change the references to reflect your form and it may need a bit of tweaking to get it working.
Niall
Views
Replies
Total Likes
You want to append the name from the Send To drop-down list to the Receiver drop-down list?
Steve
Views
Replies
Total Likes
Steve
Just to be clear, only on the new instance of the subform, if that's what you were indicating then you are correct. we're trying to automate as much possible, and to prevent user error.
Views
Replies
Total Likes
Good catch Steve!!!
"More haste less speed"
Niall
Views
Replies
Total Likes
Hi,
This should add an new item to the reviewer dropdown and set its rawValue:
// script to add instance of subform
// count the number of instances zero based numbering
var lastRow = _mySubform.count - 1;
var 2ndLastRow = lastRow - 1;
var oItem = xfa.resolveNode("mySubform[" + 2ndLastRow + "]").sentTo.rawValue;
// add the item to the dropdown
xfa.resolveNode("mySubform[" + lastRow + "]").reviewer.addItem(oItem);
// set the rawValue
xfa.resolveNode("mySubform[" + lastRow + "]").reviewer.rawValue = oItem;
However this won't check for duplicates. Steve has a good script for this: Drop-down list automatic add-on
Good luck,
Niall
Views
Replies
Total Likes
I created and attached a sample, albeit more complicated than Niall's suggestion.
Steve
Steve,
I have reviewed your example that you supplied and I don't that I explained in enough detail, because what you did was great. There is on small piece that I'm looking for the form to do, I'll try to better explain it. After you select the Reviewer and Send To fields, and click the add button, What I was hoping for was that the second instance would prepopulate the reviewer with the name from the Send To field from the previous instance. Thanks again for all of your help.
Views
Replies
Total Likes
Niall,
Thanks for all you assistance. I was trying to implement your example in my script, but I wasn't able to figure out where in my script that the items went. If you could provide some more direction it would be greatly appreciated. Thanks.
Views
Replies
Total Likes
Hi,
Here is an example:
https://acrobat.com/#d=HD6XJ1qofZDf713Yq1P43g
The first example just sets the value of the dropdown. The second adds an item to the Reviewer dropdown, as the Send to dropdown allows custom entry.
I'm been lazy though as the script should check for duplicates first. I'll try and get back to this.
Hope that helps,
Niall
Views
Replies
Total Likes
Niall and Steve
I don't know how to thank you enough for all the assistance that you provided. With all of the assistance I've gotten from this site I can finally put this form to bed! Have a great weekend.
Views
Replies
Total Likes
Views
Likes
Replies