0

I am trying to insert new Lines in AgreementLineQuantityCommitment,and they are inserted in table but do not apperar in form,the code is : Any suggestion?

LineqtyComm.initValue();
            select  firstOnly LineqtyComm where LineqtyComm.Agreement == _aggrHeader.RecId;

            LineqtyComm.initFromAgreementHeader(_aggrHeader);
            LineqtyComm.ItemId = _itemId;
            LineqtyComm.CommitedQuantity = _qty;
            LineqtyComm.ProductUnitOfMeasure = _unitOfMeasure;
            LineqtyComm.PriceUnit = _PriceUnit;
            LineqtyComm.ExpirationDate = _expirationDate;

            inventDimLoc   = LineqtyComm.inventDim();
            inventDimLoc.InventSiteId = _SiteId;
            inventDimLoc.InventLocationId = _locationId;
            inventDimLoc.wMSLocationId = _whId;
            inventDim = InventDim::findOrCreate(inventDimLoc);
            LineqtyComm.inventDimId = inventDim.inventDimId;
            LineqtyComm.LineNumber  = AgreementLine::lastLineNum(_aggrHeader.RecId) + 1.0;

            LineqtyComm.initFromInventTable();
            LineqtyComm.insert();
Axer
  • 1
  • 3
  • Capture form query in SQL profiler or trace parser and then verify inner join tables have values. Might be record missing in one or more inner join tables. – Pradeep Muttikulangara Vasu Mar 11 '17 at 21:15
  • It looks like it has to do with the buffer of the Grid,in case I have other lines and insert the new ones they appear,but when i Create a new PA without lines and try to insert they do not appear – Axer Mar 12 '17 at 09:27
  • There are several forms that use table `AgreementLineQuantityCommitment` as a data source, does this issue occur in all forms or only one? Your comment seems to indicate the `PurchAgreement` form. Please [edit] the information from your answer into your question instead of writing a comment. – FH-Inway Mar 13 '17 at 11:12

1 Answers1

0

1) Please change below lines of code. Because of this line of code LineqtyComm get initialized with exiting record value but its not happening when the record does not exits. Also LineqtyComm.initValue(); line initialization got overridden always.

LineqtyComm.initValue();

select  firstOnly LineqtyComm where LineqtyComm.Agreement == _aggrHeader.RecId;

to

select  firstOnly LineqtyComm where LineqtyComm.Agreement == _aggrHeader.RecId;
if (!LineqtyComm.Recid)
{
    LineqtyComm.initValue();
}

2) Then change below line

inventDimLoc   = LineqtyComm.inventDim();

to

inventDimLoc.clear();

As you are creating inventdim like InventDim::findOrCreate(inventDimLoc);, its better to clear instead of getting exiting lines inventdim.