Expand my Community achievements bar.

SOLVED

Increase alpha (letter) in subform when dynamically adding a new page

Avatar

Level 2

Hello all. I have a question that I am very stumped on. I know very little about scripting, but I really like LiveCycle. I am currently using LiveCycle Designer ES4, Version 11. I have successfully created a form that I can add full pages to by clicking on "Add Page" using the Instance Manager. However, I am needing the form to function as follows:

1. The alpha character needs to increase by one for each page added (A, B, C, D, E... etc.).

2. I have limited the dynamic rows for "Volunteers" to 3, and I would like to have the "Printed Name(s)" show up on the pages that are dynamically added so that they don't have to retype it on each page.

The only area that needs to be dynamic is "Volunteers". I want the user to be able to add as many pages as needed (A, B, C, D+), and each page will propagate the information from "Volunteers" to next page(s), but each occurrence of the page need only be a static page length. (ie... Page 1 will contain information for item "A", Page 2 will contain information for item "B", etc. And those individual item pages should only be one page length.)

Any help at all would be so much appreciated. I have been researching and testing this form using different methods that I have found here, but I just can't find a solution to these problems.

(I tried to upload this file, but I am getting the error "You are not allowed to create or update this content"?? So, I have attached an image of the form, which will do little good I'm sure.)

image.JPG

Thank you in advance.

Message was edited by: Aimee Stephenson

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

You can generate the letter you need with the following code in the calculate event of the TextField object (if you are using a Text object you may need to change it and make it protected and remove the caption)

String.fromCharCode(65 + Page1.index);

This assumes that Page1 is the thing that repeats.

Not sure I understand the volunteers printed name bit.  Are you saying the names are enter on the first page and then copied to every subsequent page.  If so it probably depends how you structured your table., If you have Row1, Row2 and Row3 objects then in their calculate events you could have code like;

if (Page1.index > 0) {

  PrintedName.rawValue = form1.resolveNode("Page1[0].Volunter.Row1.PrintedName").rawValue;

}

Were the Row1 part might need to change to Row2 and Row3,

Here's an example which might make more sense.  https://sites.google.com/site/livecycledesignercookbooks/home/aimee_boise.pdf?attredirects=0&d=1

Bruce

View solution in original post

6 Replies

Avatar

Correct answer by
Level 10

Hi,

You can generate the letter you need with the following code in the calculate event of the TextField object (if you are using a Text object you may need to change it and make it protected and remove the caption)

String.fromCharCode(65 + Page1.index);

This assumes that Page1 is the thing that repeats.

Not sure I understand the volunteers printed name bit.  Are you saying the names are enter on the first page and then copied to every subsequent page.  If so it probably depends how you structured your table., If you have Row1, Row2 and Row3 objects then in their calculate events you could have code like;

if (Page1.index > 0) {

  PrintedName.rawValue = form1.resolveNode("Page1[0].Volunter.Row1.PrintedName").rawValue;

}

Were the Row1 part might need to change to Row2 and Row3,

Here's an example which might make more sense.  https://sites.google.com/site/livecycledesignercookbooks/home/aimee_boise.pdf?attredirects=0&d=1

Bruce

Avatar

Level 2

Bruce,

THANK YOU SO, SO, SO MUCH! You have no idea how much this helps me out! Your answer is perfect and is working flawlessly.

To answer your question about the "Volunteer" area... I actually had it as a row that could be dynamically added up to three times, and also deleted or moved up or down the list, but with your solution, I just made three static rows. I think that will work for them just fine. My biggest hurdle was the incremental letters on dynamic page add. I could not figure that out for the life of me! Your answer has made my whole day. Thank you again so much!

-Aimee

PS.... with your help, I have also added that repeat coding to the header text fields

Avatar

Level 2

Bruce,

Sorry to be a pest... I do have one other question, and I can make it work without the answer, but I thought I would at least ask :/

Is there any way to retrain the string Unicode statement so that it will only go to 'Z', or, better yet, if it does go past 'Z', to do 'AA', 'BB', 'CC', etc., in-case they need to print more 26 pages for their location identifications?

Thank you again so much.

-Aimee

Avatar

Level 10

Hi Aimee,


I did wonder about that.  You could limit the number of pages to 26 in the binding tab by setting the max value.


If you need more than 26 you could change the calculation script to the following, which after Z will go AA, AB, AC and then after ZZ (about 700 pages), will go AAA, AAB, AAC, etc.


function alphaSequence(index)

{

    var xslt = <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

                <xsl:output method="text" media-type="text/plain"/>

                <xsl:variable name="recordNumber">{index + 1}</xsl:variable>

                <xsl:template match="/">

                    <xsl:number value="$recordNumber" format="A"/>

                </xsl:template>

            </xsl:stylesheet>;

    return $data.applyXSL(xslt.toXMLString());

}

alphaSequence(Page1.index);

I've updated my sample to make sure this works, https://sites.google.com/site/livecycledesignercookbooks/home/aimee_boiseV2.pdf?attredirects=0&d=1

This way there's a few extra options, you can change the 'format="A"' to 'format="a"' for lower case letters, or 'format="I"' for roman numbers, or 'format="001"' for 3 digit numbers with leading zeroes.

Is this sequence ok or do you need it to go "AA", "BB", "CC", etc.

Regards

Bruce

Avatar

Level 2

Bruce,

Seriously... YOU ARE THE BEST! Wow. I am going to give this a try as soon as I can.... but it might be Monday b/f I can get to it. I just have to say thank you so much for all of your help! I wish there was a way I could pay this forward, but I'm afraid my scripting knowledge is limited to scouring the internet and this wonderful community that has helped me so many times.

I hope you have a wonderful weekend, and I will let you know the outcome of your generous help.

-Aimee

Avatar

Level 2

Bruce,

Both of your suggestions worked perfectly. I was able to limit the number to 26 and to have the numbers after Z start AA, AB, AC, etc.. I can now give my users a choice in how they want their form to look. Thank you again so much for all of your help. I really appreciate it!

-Aimee