Is there a way to save a file with a unique filename using some data a user has entered (name, for ex.) that will fire when the user clicks a Print button? Attached is a file for reference.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
Yes it is working here using your latest form and the amended .js:
Have you created the "HSSSave" folder?
Also make sure the .js file is in the correct application folder and restart Acrobat:
Hope you get it working (and when you do you may want to include a datestamp or timestamp in the filename; as the script automatically overwrites an existing file with the ame name).
N.
Views
Replies
Total Likes
Using this
var
vCurrentName =
event.target.documentFileName.toString();
if
(vCurrentName =
"dateStamp + First_Name + MI + Last_Name")
app.alert("Thank you. Your form has been saved.");
else
app.alert("There was a problem. Your form has not been saved.");
I do get a message when the file is saved. However, if I change the path in the folder .js to a non-existent directory, I don't get the problem alert. Can you see what's missing in the script?
Thank you for the suggestion.
Views
Replies
Total Likes
Thank you. I finally did get the show/hide to work on change with
if (this.rawValue == null)
Button1.presence="hidden";
else
Button1.presence="visible";
Views
Replies
Total Likes
Hi,
When accessing / setting the value of an object in LC javascript use the .rawValue after the object name. Also have the double == when testing equality. Since the .js save as path is something like "2009-09-24 HSS Foot & Ankle for Patient Niall A O'Donovan.pdf", I would expect that we would need to test for this; eg the vTargetName construction matches the .js save as path.
var vTagetName = Page1.dateStamp.rawValue + " HSS Foot & Ankle for Patient " + Page1.First_Name.rawValue + " " + Page1.MI.rawValue + " " + Page1.Last_Name.rawValue + ".pdf";
if (vCurrentName == vTargetName)
....
Hope that helps,
Niall
Views
Replies
Total Likes
Yes, I'm getting close. With this
var
vTargetName = Page1.dateStamp.rawValue + " HSS Foot & Ankle for Patient " + Page1.First_Name.rawValue + " " + Page1.MI.rawValue + " " + Page1.Last_Name.rawValue +".pdf";
var
vCurrentName =event.target.documentFileName.toString();
if
(vCurrentName == vTargetName)app.alert("Thank you. Your form has been saved.");
else
app.alert("There was a problem. Your form has not been saved.");
I do get an alert when the PDF is saved. But if I modify the folder js to say var vPath = "/c/HSS/ instead of var vPath = "/c/HSSSave/ I don't get the alert "There was a problem." Do you see an error in the else condition?
Views
Replies
Total Likes
Hi,
The problem is that when the folder does not exist, the script fails and instructions after that point are not executed. The javascript console shows this up (Control +J in Acrobat).
So I moved the trusted function call to the mouseUp event and kept the file name check in the click event. This way if the trusted function fails (and that event falls over), the click event will still run after the mouseUp and when the file name check runs it will show the warning.
I know I suggested app.alert, but in this case messageBox gives better visual feedback (status or warning). Check the button script in both mouseUp and click events.
Good luck,
Niall
Views
Replies
Total Likes
That works beautifully! The form is all set, or almost. The last thing I have to do, I think, is to Enable Usage Rights in Adobe Reader, which means, I assume, opening the form in Acrobat and selecting that under Advanced. I'm about to do that and test the form out in Reader.
Thank you for all your help and advice. A couple of days ago, I was at a complete standstill. I learned a lot and want to continue studying about LC javascript and the potential of LC. I'm also going to check out Forms That Work.
Views
Replies
Total Likes
The hospital wants to add the Physician's name to the new filename. I've added a variable to the SaveAsName.js, and I've added references to Physician in the MouseUp and Click events of the button. But I think Physician must be different from First_Name, MI, and Last_Name because it involves a set of choices.
<exclGroup name="Physician" x="12.8557mm" y="51.0072mm">
Is it possible to add the selected Physician's name to the unique new filename? I've attached the folder .js file and the PDF with a new name.
Views
Replies
Total Likes
This is what I see in the Acrobat Javascript Debugger:
syntax error
4:XFA:topmostSubform[0]:Page9[0]:PrintButton1[0]:mouseUpvTargetName: 2009-09-29 Bohne HSS Foot & Ankle for Patient 1PhysicianFirst P 1PhysicianLast.pdf
vCurrentName: HSS-Foot-and-Ankle-Registration-Forms-v3copy6.pdf
The vTargetName looks OK to me. What is the syntax error?
Views
Replies
Total Likes
Hi,
A couple of things are going on here.
Firstly the vTargetName had changed to the variables (for first name etc), instead of the .rawValues of the actual fields. I have changed this.
Also I have taken out the null test for the Physician radio buttons as it is not needed.
Works OK now, good luck,
Niall
Views
Replies
Total Likes
Thank you, again, Niall, my lifeline. The form works perfectly now.
I was thrown a little when you said
Firstly the vTargetName had changed to the variables (for first name etc), instead of the .rawValues of the actual fields. I have changed this.
because I looked at the last couple of versions of the form, and they all have this syntax for the vTargetName
var vTargetName = Page1.dateStamp.rawValue + " HSS Foot & Ankle for Patient " + Page1.First_Name.rawValue + " " + Page1.MI.rawValue + " " + Page1.Last_Name.rawValue + ".pdf"; (v4)
var vTargetName = Page1.dateStamp.rawValue + " " + Page1.Physician.rawValue + " " + " HSS Foot & Ankle for Patient " + " " + Page1.First_Name.rawValue + " " + Page1.MI.rawValue + " " + Page1.Last_Name.rawValue + ".pdf";(v6)
I think I must have confused you by pasting in the error message from the Javascript Debugger, which looks like this
syntax error
4:XFA:topmostSubform[0]:Page9[0]:PrintButton1[0]:mouseUpvTargetName: 2009-09-29 Bohne HSS Foot & Ankle for Patient 1PhysicianFirst P 1PhysicianLast.pdf
vCurrentName: HSS-Foot-and-Ankle-Registration-Forms-v3copy6.pdf
Thank you for your help again. I hope everyone at the hospital is very happy with the form now.
Views
Replies
Total Likes
I don't understand the purpose of the "iProperty" in the first metioned folder level javascript.You wrote:
// folder level JavaScript to allow access to the identity object properties
trustedIdentity = app.trustedFunction( function (sProperty)
{
var iProperty = "";
app.beginPriv();
iProperty = identity[sProperty];
app.endPriv();
return iProperty;
});
However this iProperty is never called out in the LiveCycle document but equals identity[sProperty]. How do your two folder level scripts get called out, linked or associated in the document? Thanks.
Views
Replies
Total Likes
I'm sorry if I'm late to the conversation, but I've been using this script as well and have run into an issue.
It's worked well, but I am using it with a dynamic form, which the user can add table rows and nested table rows as a workorder type of thing. These rows add together to a total at the end of the document. This all works fine.
Usually the script works well, but when there are more than maybe 5 or 6 table rows, the saved document leaves the remaining rows and nested rows out. The document is incomplete compared to the fields that were actually entered.
The end calculated total reflects the lack of rows as well and doesn't include all the calculations.
It looks like it didn't finish rendering all the fields before it actually saved the file.
Are there any save limitations in Adobe Reader that could affect this?
Any insight would be greatly appreciated.
Thank you
Views
Replies
Total Likes
Hi,
there is no limitation. The problem you see may be a result of a illogical script or a bad form design.
Can you upload your form anywhere so I can check what maybe wrong?
Views
Replies
Total Likes
https://www.dropbox.com/s/s9l4wf8xyzy49bp/form-01--MIN-x.pdf
Try adding a bunch of "windows" or a bunch of "rooms", and then Save As.
When I close and reopen the file, the rows max out and don't display further.
Thanks for your help.
Views
Replies
Total Likes
Hi,
I fixed your form.
The problem was caused by the naming of the nested table row.
I renamed MainForm.roomTableSubform.roomTable.Row1.Table1.Row1 into MainForm.roomTableSubform.roomTable.Row1.Table1.Row and changed a handful of referencing scripts, and now it works as expected.
https://files.acrobat.com/preview/d730ff12-7264-4248-a2c6-440d0f5d6a25
Views
Replies
Total Likes
Amazing. Thank you so much, I'm not sure I would have ever figured that out.
Why would that be the cause? Just the Row1 nested in another Row1 of the same name?
Thank you thank you.
Views
Replies
Total Likes
From what I know it's not good to nest tables in other tables.
For those scenarios you better use subforms.
http://help.adobe.com/en_US/livecycle/9.0/designerHelp/index.htm?content=000214.html
It's also better to use unique namings for form objects to avoid unexpected side effects.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies