SubformLink using two fields on link

soltadissoltadis Member Posts: 5
Hi,

I'm trying to create a form that contains a header table and a line table, using the sales line table.

The SubformLink that I used in my customized subform is:
Document No.=FIELD(Contract No.),Group Entry No.=FIELD(No.)

My problem is that when I try to create a new record in the subform, while the Document No. is being filled automatically by the SubformLink, the "Group Entry No." field is left blank.

I have tried to solve this by adding that field as a key on the sales line table, as well as switching the order between the two fields on the SubformLink, but neither of them worked.

The other approach I used was to create a subroutine in the subform, and call it from the header. Even though the subform routine gets the value successfully, the new record begins again with that column left blank.

The subroutine is:
SetGroupEntryNo(GroupEntryNo : Integer)
"Group Entry No." := GroupEntryNo;
CurrForm.UPDATE(FALSE); // I inserted this line after reading another post suggestion on a a similar issue. I tried without that statement, but I achieve the same result.

Any idea of how can this be solved? Any suggestion will be appreciated. Thank you very much for your attention.

Comments

  • BeliasBelias Member Posts: 2,998
    set subformview property according with key fields you want to populate, it should work if you have all the necessary fields in the key
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • soltadissoltadis Member Posts: 5
    Thanks for your immediate reply. Well, I've just tried your suggestion, but it didn't work. I also played around with different combination of keys and SubformView sortings, but the "Group Entry No." column is left blank, while Document No. gets Contract No. successfully.
  • BeliasBelias Member Posts: 2,998
    can you please post what are your available keys?
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • soltadissoltadis Member Posts: 5
    Sure.

    Sales Line table keys:
    Document Type,Document No.,Line No.
    Document Type,Type,No.,Variant Code,Drop Shipment,Location Code,Shipment Date
    Document Type,Bill-to Customer No.,Currency Code
    Document Type,Type,No.,Variant Code,Drop Shipment,Shipment Date
    Document Type,Blanket Order No.,Blanket Order Line No.
    Document Type,Document No.,Location Code
    Document Type,Shipment No.,Shipment Line No.
    Type,No.,Variant Code,Drop Shipment,Location Code,Document Type,Shipment Date
    Document Type,Document No.,Type,No.
    Document Type,Sell-to Customer No.
    Document No.,Group Entry No.

    I created the last one, and also tried it inverted. Same with the sortings but nothing.
  • soltadissoltadis Member Posts: 5
    I found a workaround solution. It's not as efficient as using the SubformLink, though. Well I just made use of the aforementioned subroutine. However, instead of trying to insert the incoming parameter value into "Group Entry No." I just copied it to a global variable, which in turn I used in a lookup filter, where I intended to use the "Group Entry No." at first.

    Here is a snippet of the code in case it becomes handful to someone with a similar issue:

    // Subroutine defined on subform>>
    SetGroupEntryNo(GroupEntryNo : Integer)
    GlobalGroupEntryNo := GroupEntryNo;
    CurrForm.UPDATE(FALSE);
    // Subroutine defined on subform<<

    // Field definition on subform>>
    No. - OnLookup()
    IF MySalesHeader2.GET(GlobalGroupEntryNo) THEN BEGIN
    MyItem.SETFILTER("Item Group", MySalesHeader2."Item Group");

    IF FORM.RUNMODAL(FORM::"Item List", MyItem) = ACTION::LookupOK THEN BEGIN
    VALIDATE("No.", MyItem."No.");
    "Copy of No." := "No.";
    "Group Entry No." := GlobalGroupEntryNo; // Insert "Group Entry No." value.
    END;
    // Field definition on subform<<

    If someone finds a way to get the values for two or more fields defined on SubformLink, from the header form, please feel free to post the solution. Thank you very much for your attention.
Sign In or Register to comment.