Skip to content

Iterating through form to get detailblocks

Forums Forums SIMPOL Programming Iterating through form to get detailblocks

Tagged: 

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #3486
    JD Kromkowski
    Participant

    I have a form with 4 detailblocks. I need to update a calculated fields like calculateordertotals() does in SimpolBusiness. This is easy to do if I know the detailblock in advance, I can certainly do
    for example: dtb1 me.form!dtbName

    Or when I edit a dtb, I can get it with an ongotfocus function attached to the editfield
    dtb =@ me.formnode.key.controlsource.detailblock

    But I want to be able to generically get because different dtb have different things to total.
    So I want to iterate through, but I can seem to do that

    This code below “works” but I thought I should be able to use .getnext() or .getprev(), but it doesn’t seem to work, so I have this clunky thing.

    How do I iterate and get just the detailblocks. I don’t really understand difference between form and formnode. Is that my problem?

    dataform1detailblock dtb1, dtb2, dtb3, dtb4
    dring detblocks
    integer countdtb
    detblocks =@ me.form.detailblocks
    dtb1 =@ detblocks.head.key
    dtb2 =@ detblocks.head.prev.key
    dtb3 =@ detblocks.head.prev.prev.key
    dtb4 =@ detblocks.head.prev.prev.prev.key

    JDK

    #3487
    Michael
    Keymaster

    Hi John,

    You should be able to use something like this:

    dataform1detailblock dtb
    
    dtb =@ me.form.detailblocks.getfirst()
    while dtb !@= .nul
      // ...
      dtb =@ dtb.formnode.getnext()
    end while dtb =@= me.form.detailblocks.getfirst()
    • This reply was modified 7 years ago by Michael.
    • This reply was modified 7 years ago by Michael.
    #3490
    JD Kromkowski
    Participant

    Thanks Neil. I will take a look.

    What exactly is “formnode”.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.