I am in the process of converting my PDF forms in AEM to XDP form. For one particular date field, I have some logic coded in the exit event. I see that the exit event fires if I click over to the next field, but does not fire if I tab over to the next field. Does anyone know what I need to do so that the exit event fires consistently when I either click OR tab to the next field?
I also notice that sometimes the code I have in the enter event of certain fields seem to fire multiple times instead of just once and I don't know why that is happening. Any insight and help would be much appreciated.
Thanks,
Ravi.
Solved! Go to Solution.
Views
Replies
Total Likes
FYI, the exit event on a date field is fired in these situations:
1. When you set the value in the date field.
2. when the field lose focus due to mouse click.
3. when the field lose focus due to tab out.
To verify the script is executing every time, use the following script.
if ( this.rawValue == null || this.rawValue == "" || this.parent.LvStart.rawValue == null || this.parent.LvStart.rawValue == "" )
{
xfa.host.messageBox("Start date or end date are blank");
}
else {
xfa.host.messageBox("End date set to -"+this.rawValue);
}
if ( this.rawValue < this.parent.LvStart.rawValue)
{
xfa.host.messageBox("Leave End Date cannot be less than Leave Start Date.");
this.rawValue = "";
xfa.host.setFocus(this);
}
I tried this and this works as expected.
The issue with the enter event might be because of using setFocus() method, which invokes the Enter event only.
Hi @RaviMRam
Are you able to delete this comment here? I accidentally commented on the lock fields in the wrong thread and I just cant get this comment deleted. I wouldnt worry about it but now there are comments about the lock field having nothing to do with your thread. Ha! Again sorry about this.
For issue with Date field exit event, could you please share the logic you've implemented? We can check the issue in-house with the latest build if this is genuine issue.
For issue with events getting triggered multiple times, it could be the case that the event is propagated across the heirarchy of the form/subform. I am not sure if you're taking the PDFForm as the blueprint for creating the XDP but i'd suggest that you refer the Designer scripting guide- https://helpx.adobe.com/content/dam/help/en/experience-manager/6-5/forms/pdf/scripting-reference.pdf
Hi Pulkit,
Thanks for your time to share your comments. Somebody else had commented that if I go Edit -> Lock in designer and uncheck anything that's checked and that somehow seemed to make it better i.e. the exit event seems to fire more often (although sometimes it still doesn't). Below's my code snippet.
Yes, I am taking my PDF form and saving it as XDP and then trying to get it to work. I am hoping I can do that otherwise, it's a lot of work to start over from scratch.
Thanks for the Designer Scripting guide, but if I had the time and patience to read through a 786 page document and digest it, I wouldn't be posting here
form1.MainForm.LeaveInfo.CurrLeaveInfo.LvEnd::exit - (JavaScript, client)
if ( this.rawValue == null || this.rawValue == "" || this.parent.LvStart.rawValue == null || this.parent.LvStart.rawValue == "" )
{
}
else {
xfa.host.validationsEnabled = true;
xfa.host.messageBox("End date set to -"+this.rawValue);
if ( this.execValidate() == true )
{
if ( this.rawValue < this.parent.LvStart.rawValue)
{
xfa.host.messageBox("Leave End Date cannot be less than Leave Start Date.");
this.rawValue = "";
xfa.host.setFocus(this);
}
}
else
{
xfa.host.setFocus(this);
}
xfa.host.validationsEnabled = false;
}
--
Edit->Lock has nothing to do with the later PDF running in Adobe Acrobat/Reader and will not make anything better at runtime. It is a help to forms designers to prevent them from accidentally changing the wrong field or other objects.
Importing a PDF form created by something else is allowing you to get a headstart with the XFA based form. But it usually is not the best way of having a form as it often does not use the native XFA mechanisms. Not sure if the quirky exit script comes from the import. When I put a message box at the beginning I can see that the exit event fires even on TAB! Do you also have code in the lvStart field?
Looking at your script I try to summarize what I think you want to achieve here:
You have 2 fields, a startdate and an enddate. When the user enters the startdate and the enddate you want to make sure that the enddate is after the start and not before?
Using setFocus(this) is to force the cursor back again?
You should not use xfa.host.validationsEnabled. It covers the whole form. you can set the validation speciifically for each field and turn off the need for nullTest individually.
this.execValidate() should not be used in this way. The validation event fires with every field.
If I got your use case right then I can put together a simple sample using best practice in the form.
Otherwise explain a bit more what you want to achieve in your form.
You must not read 768 pages but a little bit of familiarization could be helpful
Kosta
FYI, the exit event on a date field is fired in these situations:
1. When you set the value in the date field.
2. when the field lose focus due to mouse click.
3. when the field lose focus due to tab out.
To verify the script is executing every time, use the following script.
if ( this.rawValue == null || this.rawValue == "" || this.parent.LvStart.rawValue == null || this.parent.LvStart.rawValue == "" )
{
xfa.host.messageBox("Start date or end date are blank");
}
else {
xfa.host.messageBox("End date set to -"+this.rawValue);
}
if ( this.rawValue < this.parent.LvStart.rawValue)
{
xfa.host.messageBox("Leave End Date cannot be less than Leave Start Date.");
this.rawValue = "";
xfa.host.setFocus(this);
}
I tried this and this works as expected.
The issue with the enter event might be because of using setFocus() method, which invokes the Enter event only.
Views
Likes
Replies