Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list

Live Cycle script for auto filling dates

Avatar

Level 1

I have created a form and used formcalc to auto fill dates. I select the first date and it is supposed to fill in the next two weeks. It works if the date is 2 digits like 12/17/15 but not 12/4/15. Can anyone let me know what I am doing wrong?

This is what I have. I am very new to script and basically used trial and error on what I found online.

</script>

            </calculate>

            <?PDF_OBJR NumericField2[0]?>

        </field>

        <field name="NumericField3" y="179.459mm" x="65.944mm" w="23.541mm" h="8.544mm">

            <ui>

              <numericEdit>

                  <border hand="right">

                    <?templateDesigner StyleID aped3?>

                    <edge stroke="lowered" cap="butt"/>

                  </border>

                  <margin/>

              </numericEdit>

            </ui>

            <font typeface="Myriad Pro"/>

            <para vAlign="middle" hAlign="center"/>

            <?PDF_OBJR NumericField3[0]?>

        </field>

        <field name="mondaydate" y="48.21mm" x="166.241mm" w="36.443mm" h="7.898mm">

            <ui>

              <dateTimeEdit>

                  <border hand="right" presence="hidden">

                    <?templateDesigner StyleID aped0?></border>

              </dateTimeEdit>

            </ui>

            <font typeface="Myriad Pro"/>

            <para vAlign="middle" hAlign="center"/>

            <value>

              <date/>

            </value>

            <format>

              <picture>date{MMMM DD, YYYY}</picture>

            </format>

            <validate nullTest="error"/>

            <?PDF_OBJR mondaydate[0]?></field>

        <field name="beginDate" y="92.228mm" x="43.049mm" w="22.902mm" h="5.479mm">

            <ui>

              <dateTimeEdit>

                  <border hand="right" presence="hidden">

                    <?templateDesigner StyleID aped0?></border>

                  <margin/>

              </dateTimeEdit>

            </ui>

            <font typeface="Myriad Pro"/>

            <para vAlign="middle"/>

            <value>

              <date/>

            </value>

            <calculate>

              <script>$=mondaydate

</script>

            </calculate>

            <validate nullTest="error"/>

            <?PDF_OBJR beginDate[0]?></field>

        <field name="Date2" y="98.036mm" x="43.049mm" w="22.414mm" h="5.32mm" access="readOnly">

            <ui>

              <textEdit>

                  <border hand="right" presence="hidden">

                    <?templateDesigner StyleID aped0?></border>

                  <margin/>

              </textEdit>

            </ui>

            <font typeface="Myriad Pro"/>

            <para vAlign="middle" use="designer__defaultWidowOrphanSettings.para"/>

            <?PDF_OBJR Date2[0]?>

            <calculate>

              <script>$=Num2Date(Date2Num(beginDate.formattedValue,"MMM DD, YYYY")+01,"MMM DD, YYYY")

</script>

            </calculate>

        </field>

        <field name="TextField1" y="103.679mm" x="43.049mm" w="22.737mm" h="5.32mm" access="readOnly">

            <ui>

              <textEdit>

                  <border hand="right" presence="hidden">

                    <?templateDesigner StyleID aped0?></border>

                  <margin/>

              </textEdit>

            </ui>

            <font typeface="Myriad Pro"/>

            <para vAlign="middle" use="designer__defaultWidowOrphanSettings.para"/>

            <calculate>

              <script>$=Num2Date(Date2Num(beginDate.formattedValue,"MMM DD, YYYY")+2,"MMM DD, YYYY")

</script>

            </calculate>

            <?PDF_OBJR TextField1[0]?></field>

        <field name="TextField2" y="114.801mm" x="43.049mm" w="22.091mm" h="5.32mm" access="readOnly">

            <ui>

              <textEdit>

                  <border hand="right" presence="hidden">

                    <?templateDesigner StyleID aped0?></border>

                  <margin/>

              </textEdit>

            </ui>

            <font typeface="Myriad Pro"/>

            <para vAlign="middle" use="designer__defaultWidowOrphanSettings.para"/>

            <calculate>

              <script>$=Num2Date(Date2Num(beginDate.formattedValue,"MMM DD, YYYY")+4,"MMM DD, YYYY")

</script>

            </calculate>

            <?PDF_OBJR TextField2[1]?></field>

        <field name="TextField3" y="109.322mm" x="43.049mm" w="22.573mm" h="5.32mm" access="readOnly">

            <ui>

              <textEdit>

                  <border hand="right" presence="hidden">

                    <?templateDesigner StyleID aped0?></border>

                  <margin/>

              </textEdit>

            </ui>

            <font typeface="Myriad Pro"/>

            <para vAlign="middle" use="designer__defaultWidowOrphanSettings.para"/>

            <calculate>

              <script>$=Num2Date(Date2Num(beginDate.formattedValue,"MMM DD, YYYY")+3,"MMM DD, YYYY")

</script>

            </calculate>

            <?PDF_OBJR TextField3[0]?></field>

        <field name="TextField4" y="120.608mm" x="43.049mm" w="22.414mm" h="5.643mm" access="readOnly">

            <ui>

              <textEdit>

                  <border hand="right" presence="hidden">

                    <?templateDesigner StyleID aped0?></border>

                  <margin/>

              </textEdit>

            </ui>

            <font typeface="Myriad Pro"/>

            <para vAlign="middle" use="designer__defaultWidowOrphanSettings.para"/>

            <calculate>

              <script>$=Num2Date(Date2Num(beginDate.formattedValue,"MMM DD, YYYY")+5,"MMM DD, YYYY")

</script>

            </calculate>

            <?PDF_OBJR TextField4[0]?></field>

        <field name="TextField4" y="125.606mm" x="43.049mm" w="22.414mm" h="5.643mm" access="readOnly">

            <ui>

              <textEdit>

                  <border hand="right" presence="hidden">

                    <?templateDesigner StyleID aped0?></border>

                  <margin/>

              </textEdit>

            </ui>

            <font typeface="Myriad Pro"/>

            <para vAlign="middle" use="designer__defaultWidowOrphanSettings.para"/>

            <calculate>

              <script>$=Num2Date(Date2Num(beginDate.formattedValue,"MMM DD, YYYY")+6,"MMM DD, YYYY")

</script>

            </calculate>

            <?PDF_OBJR TextField4[1]?></field>

        <field name="TextField4" y="131.572mm" x="43.049mm" w="22.414mm" h="5.643mm" access="readOnly">

            <ui>

              <textEdit>

                  <border hand="right" presence="hidden">

                    <?templateDesigner StyleID aped0?></border>

                  <margin/>

              </textEdit>

            </ui>

            <font typeface="Myriad Pro"/>

            <para vAlign="middle" use="designer__defaultWidowOrphanSettings.para"/>

            <calculate>

              <script>$=Num2Date(Date2Num(beginDate.formattedValue,"MMM DD, YYYY")+7,"MMM DD, YYYY")

</script>

            </calculate>

            <?PDF_OBJR TextField4[2]?></field>

        <field name="TextField4" y="137.056mm" x="43.049mm" w="22.414mm" h="5.643mm" access="readOnly">

            <ui>

              <textEdit>

                  <border hand="right" presence="hidden">

                    <?templateDesigner StyleID aped0?></border>

                  <margin/>

              </textEdit>

            </ui>

            <font typeface="Myriad Pro"/>

            <para vAlign="middle" use="designer__defaultWidowOrphanSettings.para"/>

            <calculate>

              <script>$=Num2Date(Date2Num(beginDate.formattedValue,"MMM DD, YYYY")+8,"MMM DD, YYYY")

</script>

            </calculate>

            <?PDF_OBJR TextField4[3]?></field>

        <field name="TextField4" y="142.699mm" x="43.049mm" w="22.414mm" h="5.643mm" access="readOnly">

            <ui>

              <textEdit>

                  <border hand="right" presence="hidden">

                    <?templateDesigner StyleID aped0?></border>

                  <margin/>

              </textEdit>

            </ui>

            <font typeface="Myriad Pro"/>

            <para vAlign="middle" use="designer__defaultWidowOrphanSettings.para"/>

            <calculate>

              <script>$=Num2Date(Date2Num(beginDate.formattedValue,"MMM DD, YYYY")+9,"MMM DD, YYYY")

</script>

            </calculate>

            <?PDF_OBJR TextField4[4]?></field>

        <field name="TextField4" y="148.501mm" x="43.049mm" w="22.414mm" h="5.643mm" access="readOnly">

            <ui>

              <textEdit>

                  <border hand="right" presence="hidden">

                    <?templateDesigner StyleID aped0?></border>

                  <margin/>

              </textEdit>

            </ui>

            <font typeface="Myriad Pro"/>

            <para vAlign="middle" use="designer__defaultWidowOrphanSettings.para"/>

            <calculate>

              <script>$=Num2Date(Date2Num(beginDate.formattedValue,"MMM DD, YYYY")+10,"MMM DD, YYYY")

</script>

            </calculate>

            <?PDF_OBJR TextField4[5]?></field>

        <field name="TextField4" y="154.308mm" x="43.049mm" w="22.414mm" h="5.643mm" access="readOnly">

            <ui>

              <textEdit>

                  <border hand="right" presence="hidden">

                    <?templateDesigner StyleID aped0?></border>

                  <margin/>

              </textEdit>

            </ui>

            <font typeface="Myriad Pro"/>

            <para vAlign="middle" use="designer__defaultWidowOrphanSettings.para"/>

            <calculate>

              <script>$=Num2Date(Date2Num(beginDate.formattedValue,"MMM DD, YYYY")+11,"MMM DD, YYYY")

</script>

            </calculate>

            <?PDF_OBJR TextField4[6]?></field>

        <field name="TextField4" y="159.787mm" x="43.049mm" w="22.414mm" h="5.643mm" access="readOnly">

            <ui>

              <textEdit>

                  <border hand="right" presence="hidden">

                    <?templateDesigner StyleID aped0?></border>

                  <margin/>

              </textEdit>

            </ui>

            <font typeface="Myriad Pro"/>

            <para vAlign="middle" use="designer__defaultWidowOrphanSettings.para"/>

            <calculate>

              <script>$=Num2Date(Date2Num(beginDate.formattedValue,"MMM DD, YYYY")+12,"MMM DD, YYYY")

</script>

            </calculate>

            <?PDF_OBJR TextField4[7]?></field>

        <field name="TextField4" y="165.107mm" x="43.049mm" w="22.414mm" h="5.643mm" access="readOnly">

            <ui>

              <textEdit>

                  <border hand="right" presence="hidden">

                    <?templateDesigner StyleID aped0?></border>

                  <margin/>

              </textEdit>

            </ui>

            <font typeface="Myriad Pro"/>

            <para vAlign="middle" use="designer__defaultWidowOrphanSettings.para"/>

            <calculate>

              <script>$=Num2Date(Date2Num(beginDate.formattedValue,"MMM DD, YYYY")+13,"MMM DD, YYYY")

Below are screen shots of what is is doing.

Capture single digit.JPG

Capture 2 digit.JPG

  Thank you for any help you can provide.

0 Replies

The ultimate experience is back.

Join us in Vegas to build skills, learn from the world's top brands, and be inspired.

Register Now