Quantcast
Channel: Dynamics User Group
Viewing all articles
Browse latest Browse all 15740

Purchase packing slip posting by code

$
0
0

Hi all,

I am trying to do purchase packing slip posting by code. In my case, at the time of posting Packing slip, I have some qty in PurchLine > PurchreceiveNow, which should be posted in Packing slip.

I tried that by two ways

1)

PurchTable purchTable = PurchTable::find(<purchId>);

PurchFormLetter purchFormLetter = PurchFormLetter::construct(DocumentStatus::PackingSlip);

;

purchFormLetter.update(purchTable, <Packing slip no>, systemDateGet(), PurchUpdate::ReceiveNow);

2) purchFormLetter         purchFormLetter;
      purchid                 PurchId;
      PurchTable              PurchTable;
      purchparmtable          purchParmtable;
      ParmId                  parmId;
      num                     packingSlipId;
      purchline               purchline;
      purchparmline           purchparmline;
      ;
  
      packingSlipId=< my packing slip no>;
      PurchId=   <my purch id>;
      PurchTable=PurchTable::find(purchid);
      purchFormLetter = PurchFormLetter::construct(DocumentStatus::PackingSlip);
      parmid=purchFormLetter.parmId(NumberSeq::newGetNum(CompanyInfo::numRefParmId()).num());
      parmId= purchFormLetter.parmId();
      purchFormLetter.createParmUpdate();
      purchParmtable= purchParmtable::find(purchid,parmid);
      purchFormLetter.createParmTable(purchParmTable,purchTable);
      purchParmTable.Num = packingSlipId;
      purchParmTable.insert();
      while select purchLine
          where purchLine.PurchId == purchTable.purchId
             && (purchLine.RemainPurchPhysical > 0)
      {
          purchParmLine.ParmId = purchParmTable.ParmId;
          purchParmLine.InitFromPurchLine(purchLine);
          purchParmLine.ReceiveNow = PurchLine.PurchReceiveNow;
  
      purchParmLine.setQty(DocumentStatus::PackingSlip,false, true);
      purchParmLine.setLineAmount();
      purchParmLine.insert();
      }
      purchFormLetter.proforma       (false);
      purchFormLetter.printFormLetter(true);
      purchFormLetter.specQty        (PurchUpdate::ReceiveNow);
      purchFormLetter.transDate      (today());
      purchFormLetter.run();

But, when in check in PurchFormLetter>QueryBuild(), query have no records, so it wont post the packing slip.

Any idea, what I am missing!!

 


Viewing all articles
Browse latest Browse all 15740

Trending Articles