How do I varify a field in subform

koaladokoalado Member Posts: 70
When I submit a PO for approval, I want to check each purchase line if they meet our rules
for Item, Dimension Costcenter Must Not Inputed.
for G/L , Dimension Costcenter Must Inputed.
for others, Dimension Costcenter Must Not Inputed.
What should I do?
Thanks a lot

Comments

  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    What kind of transaction is a "aproval"?

    You can write a function in the purchase header with a returnvalue boolean.

    In the function you write some code for the checks, if it is correct you return TRUE, otherwise FALSE.
  • koaladokoalado Member Posts: 70
    How could I check field 'costcenter' value of table "purchase line" in table "purchase header"'s function?
    Thanks
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
  • koaladokoalado Member Posts: 70
    Thanks for your reply. Yes. It's shortcut of Dimension
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    In that case, you can define a local varable of type record 39.

    Create some code like
    PurchLine.Setrange("Document No.", "No.");
    PurchLine.Setrange("Document Type", "Document Type");
    IF PurchLine.Find('-') then
      repeat
        if (purchline.type = purchline.type::"G/L Account") and
          (purchline."Shortcut Dimension 1 Code" = '')
        then
          exit(FALSE);
        if  (purchline.type <> purchline.type::"G/L Account") and
          (purchline."Shortcut Dimension 1 Code" <> '') 
        then
          exit(FALSE);
      until purchline.next = 0;
    
    exit(TRUE);
    

    You can also use
    PurchLine.Setrange("Document No.", "No.");
    PurchLine.Setrange("Document Type", "Document Type");
    IF PurchLine.Find('-') then
      repeat
        if purchline.type = purchline.type::"G/L Account" then
            purchline.testfield("Shortcut Dimension 1 Code")
        else
            purchline.testfield("Shortcut Dimension 1 Code", '')
      until purchline.next = 0;
    

    But this does not use the return value
  • koaladokoalado Member Posts: 70
    Thanks a lot !
Sign In or Register to comment.