7 Replies Latest reply on Oct 15, 2012 4:57 AM by willrollo

    First week..

      Title

      First week..

      Post

      I am trying to automate a letter that will automatically write first/second/third etc week of month when sourcing the date from a date field. What calculation woudl I need to enable this?

      Thanks

        • 1. Re: First week..
          philmodjunk

          So If the date is March 1, 2 or 3, you want the letter to display "First Week of March, 2012"?

          Date - Day ( Date ) + 1 will be the date of the first day of the month. Using that date, we can return the week of the month:

          Let ( [ D = YourDateField ;
                     m1 = D - Day ( D ) + 1;
                   ] ;
                   WeekOfYear ( D ) - WeekOfYear ( m1 ) + 1
                 )

          Will return a number for the week of the month. From there it's a matter of a calculation to convert the number into the desired text to use in your letter.

          • 2. Re: First week..

            That's great, thank you.

            Just wondering, is there a simple way of adding certain criterie to a preview layout for printing?

            I want to add a certain paragraph to some letters depending on whether a Yes/No is in theire initial customer record. Or do Ihave to use different layouts to show this and select the layout from an IF statement?

            Also, is there a way to print automatically without having to Go to Layout, Preview mode, print, close window?

            I would like the databse to send off a sting of print commands and the touch of a button without the user haveinbg to look at them all as they are from different layouts..

            Thanks!

            • 3. Re: First week..
              philmodjunk

              I want to add a certain paragraph to some letters depending on whether a Yes/No is in theire initial customer record. Or do Ihave to use different layouts to show this and select the layout from an IF statement?

              You can put that paragraph inside a text field and put a calculaiton field on your layout that returns "" or the contents of that text field depending on the "yes/no" value.

              Also, is there a way to print automatically without having to Go to Layout, Preview mode, print, close window?

              That's what scripts are for. A script can select the layout and print with specified print options at the click of a button. There's no need to enter preview mode nor open any additional windows.

              • 4. Re: First week..

                Thank you Phil

                I assumed scripts are indeed for that, but I cannot see how to do it in the background without opening a new window or changing to the layout i wish to print from..Could you tap out a brief example??? Thank you

                • 5. Re: First week..
                  philmodjunk

                  You have to be able to switch to the layout for which you will print, either in the same window or a different window, but this need not be visible to the user.

                  Freeze window
                  Go to Layout [//select print layout]
                  Print [restore, no dialog]
                  Go to layout [original layout]

                  The script changes layout, but the user does not see the change in layout.

                  • 6. Re: First week..

                    Perfect! Thank you

                    • 7. Re: First week..

                           Hi Phil,

                           I have re posted this in case you are no longer subscribed to this - 

                           I have come back to this original issue as it appears that this calc/cond format has a few issues since I redid the my db.

                           I cannot see why though as the fields seem to contain the same properties and data, but the result is not the correct one.

                           using this conditional format 

                            

                           Let ( [ d = Invoiceitems_INVOICE::Week of month ;

                                      

                                      $$number = If ( d < 5 ; Choose ( d ; "" ; "We anticipate your fender being ready by the first week of " ; "We anticipate your fender being ready by the second week of " ; "We anticipate your fender being ready by the third week of " ) ;  "We anticipate your fender being ready by the last week of " ) & Invoiceitems_INVOICE::Month & ", and will advise you nearer the time. 

                            

                           Please do not hesitate to telephone or email us if you would like to know how your fender is progressing. Our  order reference is given above."

                                     ] ;

                                      True )

                            

                           The resulting data in the field just reads " December (for example), and will advise you nearer the time. .

                            

                           The field, Invoiceitems::INVOICE::Week of month does calculate the correct result to trigger this - ie. a number from 0-5 depending on the day of the month.

                           Any idea why this is happening?  The layout is based on the Invoiceitems::INVOICE table occurance.

                           Thank you