Showing posts with label Nav 365. Show all posts
Showing posts with label Nav 365. Show all posts

Monday, 24 August 2020

Business Central 365 get max value AL/CAL

 MyTable.RESET;

MyTable.SETCURRENTKEY(Field1,Field2,Field3);
// If Required
MyTable.SETRANGE(Field1,Field1);
MyTable.SETRANGE(Field2,Field2);
IF MyTable.FIND('+') then
message('This is the max. value of Field3: ',MyTable.Field3);

Wednesday, 17 July 2019

Nav 365 C/AL create a purchase order

counter :=0;

PurchHeader.INIT;
//PurchHeader.INIT();
PurchHeader."Document Type":= PurchHeader."Document Type"::Order;
PurchHeader."Vendor Invoice No.":='123';
PurchHeader.VALIDATE("Posting Date",TODAY);
PurchHeader.VALIDATE("Buy-from Vendor No.",'10000');

PurchHeader.INSERT(TRUE);
COMMIT;

CurrPage.SETSELECTIONFILTER(SalesInvoiceLine);

 REPEAT
   PurchaseLine.INIT();
   PurchaseLine.CLEARMARKS;
   MESSAGE(FORMAT(PurchHeader."No."));
   counter := counter+1;
  PurchaseLine."Line No.":=counter;
  PurchaseLine."Document Type":=PurchHeader."Document Type";
  PurchaseLine."Document No.":=PurchHeader."No.";
  PurchaseLine.VALIDATE(Type,PurchaseLine.Type::Item);
  PurchaseLine.VALIDATE("No.",'70062');
  PurchaseLine.VALIDATE("Direct Unit Cost",90);
  //PurchaseLine.Quantity
  PurchaseLine.VALIDATE(Quantity,10);
  PurchaseLine.INSERT(TRUE);
  COMMIT;
 UNTIL SalesInvoiceLine.NEXT = 0;

Nav 365 loop through the selected records

Hello Nav my first post ;)

//lSalesLine is a local record variable that points to "Sales Line" table.
CurrPage.SETSELECTIONFILTER(lSalesLine);
IF lSalesLine.FINDSET THEN
 REPEAT
   MESSAGE(FORMAT(lSalesLine));
 UNTIL lSalesLine.NEXT = 0;