This discussion is archived
2 Replies Latest reply: Jan 7, 2013 3:03 AM by 979471 RSS

Procedure to Add a common section in all forms using PostTrans DAL

979471 Newbie
Currently Being Moderated
I am looking for a solution to add a common image across all forms using a single Posttrans DAL. It would be great help if anyone could give suggestion to implemnet the same. Please find my sample DAL below.

#totalpages = TOTALPAGES("recepient")
#image_counter = 1

while (#image <= #totalpages)

ImageName = PageImage(#image);

AddImage("Image to be added",ImageName,,,1);

#pos.top = 24600
#pos.left = 1300

SetImagePos("#pos","Image to be added");

#ValueForCommonSection = GetData("31,01,506,0092 39,5");

SetFld(#ValueForCommonSection,"#Variable In Common Section","Image to be added");

#image_counter = #image_counter + 1;

wend;
  • 1. Re: Procedure to Add a common section in all forms using PostTrans DAL
    user9976634 Journeyer
    Currently Being Moderated
    Unfortunately, there is not enough information to determine your exact goal, so I will offer some general tips.

    First, the TOTALPAGES() function may not return what you expect. This is because this function returns the count of physical pages that will print for the recipient which does not necessarily correspond to logical pages you have defined in the document. For instance, you could have one page in the document defined with the recipient copy count on a section set to 3. In that case TOTALPAGES(“for that recipient”) will return 3. In your scenario, you only need to add a section to page 1 and there are no “real” pages for 2 or 3. This is just for your information though as in this case, you really don’t need to use that function anyway.

    You say you want to add this section to each page. If that is the case, then you can just have a loop that starts at 1 and counts forward and break the loop when PAGEIMAGE() returns an empty string. If you ask for the name of a section on a logical page that does not exist, the function will return no name.

    When you add a section as you are, the new section takes on the recipients of the section you named as the insertion point. So, if you really do care about the recipient then you need to specify this recipient as a parameter in the PAGEIMAGE() function.

    IName=PageImage(#pageno, “MyRecipient”).

    This way, you are only looking at pages that will print for the given recipient. Although you were using the TOTALPAGES() function with a recipient, nothing in the subsequent code seemed to care, so I’m going to assume that you are not really recipient specific and will omit the “MyRecipient” parameter in my example.

    Now at this point it is important to note that your script is trying to use a variable name that is a reserved word. ImageName is the name of a function. So, the statement ImageName=PageImage() is going to generate a syntax error and fail. You need a different variable name. I’ll use IName.

    Next as a point of efficiency, there is no reason to do your GetData function inside the loop. You are repeating the same search over and over. Get the data outside the loop and then just assign the result into your variable. Then you can assign the variable into your field over and over with the same value.

    This brings us to the point where I have to admit that DAL is all powerful and also all dumb. The dumb part in this case is because you are calling this function from a Post-Transaction rule. Because of this, you will have to be more specific with your parameters for names of sections and/or fields in order to find the correct occurrence that you wish to affect.

    For instance, you have this statement in your loop:

    SetFld(#ValueForCommonSection,"#Variable In Common Section","Image to be added");

    Although on the surface this seems correct, you have to be very specify on the “Image to be added” part. The first one you add may be found just fine, but what about the second? If you don’t include occurrence information – or something more specific on how to find the section – then you just end up setting the field on the first page over and over and all your other pages have a blank value in the field.

    When you are doing Entry or DAL on specific field rules during routine mapping, DAL has knowledge of the “current” section and/or field that you are addressing. When you are using a Pre- or Post-Transaction level rule, DAL will assume the first section in the entire document is the “current” one, so you have to be more specific to locate repeating items throughout the document.

    In the end, this is my interpretation of what you are intending. Depending upon the version you are using, you may have to remove the comment lines that have the //. I'll include them here just for clarification.

    //Get Data value outside of loop one for reuse
    #ValueForCommonSection = GetData("31,01,506,0092 39,5");
    //start page count from 1
    #pageno = 1
    While(1)
    //Get first section this page and it will contains occurrence if needed
    iName=PageImage(#pageno)
    // If we got no name, then we have no more pages
    if (iName="")
    break;          
    end
    // assign the section name to be add into a variable
    qName = "Image to be added"
    // adding the section by specific occurrence reference
    AddImage(qName,iName,,"*",1)
    // now add the occurrence of my newly added section
    qName = qName & “\” & #pageno
    // new position
    #pos.top=24600
    #pos.left=1300
    // now set position to specific occurrence just added
    SetImagePos("#pos", qName,,"*");
    // set field on this occurrence of section just added
    SetFld(#ValueForCommonSection,,"#Variable In Common Section", qName,,"*")
    // increment page count.
    #pageno += 1
    Wend

    Finally, I want to point out one more potential fly in the ointment. If you are going straight to print, this should work. If you intend for this to go to Entry for further editing by an end user, then additional scripting or some different document design is going to be required.

    This is because you are trying to position the section somewhere near the bottom of the page, but the next effect is that this is now the second “physical” section defined on the page. If you were to kick this transaction to WIP and then edit it in Entry, you could end up affecting the origins of the sections that follow. So keep that in mind.
  • 2. Re: Procedure to Add a common section in all forms using PostTrans DAL
    979471 Newbie
    Currently Being Moderated
    I believe no one in this world could have provided a better answer for my question as yours.

    Thankyou so much as this idea of mine became true only because of your splendid clarification on POSTTRANS DAL concept and its attributes. I made some alterations to your sample code and it worked exactly the way i expected.

    As you said i am now trying to improvise the code to suit overflow and user entry features.

    Once again a Heartfelt thanks to you help.

    Regards,
    Barathraj T

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points