Unexpected effects

Avatar

Avatar

martynd4832568

Avatar

martynd4832568

martynd4832568

20-11-2016

I'm using Lifecycle ES4. I have a form in which one of 5 company logos is selected from a drop down field. That selection also fills in the appropriate contact information for the selected company.

My problem is when a text field (called facilityName) is completed by the user,  the logo disappears. There is no script associated with the field facilityName (I checked using the Script Indicator). This disappearing act is also triggered by two more text fields  neither of which has script associated.  I have run out of ideas as to what is going on here. Any input or crazy ideas gratefully received! I am a newbie at this, so please bear with my novice mistakes.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

_Bruce_Robertson

MVP

Total Posts

1.8K

Likes

268

Correct Answer

371

Avatar

_Bruce_Robertson

MVP

Total Posts

1.8K

Likes

268

Correct Answer

371
_Bruce_Robertson
MVP

24-11-2016

Hi Martyn,

Try this version, https://sites.google.com/site/livecycledesignercookbooks/home/20161117%20v2%20-%20marked%20up%20for%...  .  I didn't look close enough at how the master pages were selected, I have now added some defensive code in to handle the master page selection.

The problem you have found with having break on exceptions turned on is if the exception is thrown before Acrobat actually has the document open nothing seems to happen.  You can either open Acrobat and then open the pdf (don't just double click the pdf file or use "open with" ... Acrobat has to be up and running, so use File ... Open or drag and drop the file onto Acrobat), alternatively you can set "When exception is thrown" to trace and you will get a list of the exceptions but Acrobat will continue.

Regards

Bruce

Answers (7)

Answers (7)

Avatar

Avatar

_Bruce_Robertson

MVP

Total Posts

1.8K

Likes

268

Correct Answer

371

Avatar

_Bruce_Robertson

MVP

Total Posts

1.8K

Likes

268

Correct Answer

371
_Bruce_Robertson
MVP

29-11-2016

Hi Martyn,

I just meant changing the code

var imageField = xfa.resolveNode("form1.#pageSet.Page1["+ i + "].ImageField1");          

imageField.rawValue = imageData;

to

var imageField = xfa.resolveNode("form1.#pageSet.Page1[" + i + "].ImageField1");          

if (imageField != null)

{

    imageField.rawValue = imageData;

}

That is add the test for not equal null, in case the other master page was in use.

Regards

Bruce

Avatar

Avatar

martynd4832568

Avatar

martynd4832568

martynd4832568

28-11-2016

Hi Bruce

Brilliant! Works like a charm, thank you so much. Could you point me in the direction of the defensive code, as I would like to see what you did? - I may need something similar in the future!

Many thanks again.

Avatar

Avatar

martynd4832568

Avatar

martynd4832568

martynd4832568

23-11-2016

Hi Bruce - I spotted a problem with the form you sent me. The logo issue is good, but the rest of the statement (in italics below) does not perform i.e the floating fields are not populating

if(this.rawValue ==1)

{

  xfa.resolveNode("form1.#pageSet.Page1[0].ImageField1").rawValue = null;

}

else

if(this.rawValue ==2)

{

  var imageData = xfa.resolveNode("form1.#pageSet.Page1[0].EMWD").value.oneOfChild.value;

  for (var i = 0; i < xfa.host.numPages; i++)

  {

  var imageField = xfa.resolveNode("form1.#pageSet.Page1[" + i + "].ImageField1");

  imageField.rawValue = imageData;

  var imageField = xfa.resolveNode("form1.#pageSet.Page2[" + i + "].ImageField1");

  imageField.rawValue = imageData;

  }

  xfa.resolveNode("form1.Cover.UnNamed.ff_AgencyName").rawValue = "Eastern Municipal Water District";

  //Cover.UnNamed.ff_AgencyName.rawValue = "Eastern Municipal Water District";

  xfa.resolveNode("form1.Cover.ff_AA").rawValue = "EMWD";

  xfa.resolveNode("form1.Cover.ff_AgencyOrd").rawValue = " Ordinance 1234";

  xfa.resolveNode("form1.Cover.AgencySigner").rawValue = "Gregg Murray";

  xfa.resolveNode("form1.Cover.AgencyTitle").rawValue = "Source Control Manager";

  xfa.resolveNode("form1.Cover.AgencyName").rawValue = "Eastern Municipal Water District";

  xfa.resolveNode("form1.Permit.ff_AgencyName2").rawValue = "Eastern Municipal Water District";

  xfa.resolveNode("form1.Permit.ff_AgencyName2").rawValue = "Eastern Municipal Water District";

  xfa.resolveNode("form1.Permit.ff_AgencyName3").rawValue = "Eastern Municipal Water District";

  xfa.resolveNode("form1.Permit.ff_AgencyAddress").rawValue = "2270 Trumble Road";

  xfa.resolveNode("form1.Permit.ff_AgencyCity").rawValue = "Perris";

  xfa.resolveNode("form1.Permit.ff_AgencyStateZip").rawValue = "CA 92572";

  xfa.resolveNode("form1.Permit.ff_AgencyPhone").rawValue ="Phone: (951)928-3777 ext. 6216"

  xfa.resolveNode("form1.Permit.ff_AgencyEmergency").rawValue ="Emergency Phone: 911-911-911";

  xfa.resolveNode("form1.Permit.pff_AgencyResolution[1]").rawValue = "Ordinance Number goes here";

}

I've tried all variations of addressing the floating field, but nothing works so far. Any suggestions gratefully received!

Avatar

Avatar

martynd4832568

Avatar

martynd4832568

martynd4832568

23-11-2016

Hi Bruce

Many, many thanks! I have taken a very quick look at your modifications, and it's going to take me a while to get my head round them - way above my knowledge/skill level!!

I know I have some housekeeping to do on the form, getting rid of bad references etc., but I had to get this logo issue working first, otherwise the entire form was a no-go. This may be a a case of putting the cart before the horse...

Regarding the "When exception is thrown", I set it to "Break" but when I try and open the pdf, in Adobe, or preview it in LC, the form doesn't open at all. I think this means that there is a problem but this is not allowing me to track it down. Any suggestions?

Again, many thanks for taking the time to look at this for me.

Avatar

Avatar

_Bruce_Robertson

MVP

Total Posts

1.8K

Likes

268

Correct Answer

371

Avatar

_Bruce_Robertson

MVP

Total Posts

1.8K

Likes

268

Correct Answer

371
_Bruce_Robertson
MVP

22-11-2016

Hi Martyn,

It makes sense having the images on the master page but scripting changes to form object properties on a master page will be reverted to their initial values when a re-layout occurs.  In your case this was when the Facility Name (or Site Address) that are used in a
floating field are updated (if you change the binding of these floating fields then the images are retained).

So, one way around this is to use an ImageField object with a bound value, so doesn’t get reset.

I’ve updated your sample to demonstrate this; https://sites.google.com/site/livecycledesignercookbooks/home/20161117%20v2%20-%20marked%20up%20for%...

The new ImageField is called ImageField1 and the code in the Choose Agency dropdown list has been changed to populate this field with the image data from the Image objects you had.  There is a line of code in the ImageField1 initialise event to set the field to read only (as this setting is not available in the Designer UI).  I have also changed to code to calculate how many master pages need to be
updated.  Your form is throwing a number of exceptions, including referencing master pages that don’t exist, do you have "When exception is thrown" set to Break under Edit ... Preferences ... JavaScript in Acrobat?

Regards

Bruce

Avatar

Avatar

martynd4832568

Avatar

martynd4832568

martynd4832568

21-11-2016

Hi Bruce

Thanks for the suggestions. The logo is not bound to anything, and does not have a calculated script. I checked this using the script and binding indicators.

The form can be downloaded from this link:

I have color-coded the agencyName text field in green, and the troublesome fields in pink. So, the Agency name is chosen from the green field, and the correct logo appears, but when one of the pink fields is filled in, the logo disappears. I did notice that just tabbing through the pink field does NOT make the logo disappear - i don't know if that helps you or not.

Any help would be wonderful!

Thanks in advance

Martyn

Avatar

Avatar

_Bruce_Robertson

MVP

Total Posts

1.8K

Likes

268

Correct Answer

371

Avatar

_Bruce_Robertson

MVP

Total Posts

1.8K

Likes

268

Correct Answer

371
_Bruce_Robertson
MVP

21-11-2016

Hi,

It might be easier to upload your form to a file sharing site like Google Docs, DropBox, etc and post a link here.

Is the logo bound to anything?  Does it have a calculate script somewhere, that refers to the text fields.

Regards

Bruce