Discussion:
Updating LocationId on a PO Line
(too old to reply)
David Castillo
2008-05-15 19:15:02 UTC
Permalink
I'm trying to update a PO line from code.
I have a form that opens from the PO line passing the PO line record.
On that form, I update a location field that I want to carry over to the PO
line record.
I have code on that form to do an update of the InventDim table based on the
PO's InventDimId.
When I debugg it, it updates fine but when I refresh the PO line record, it
still has the original LocationId that was on the PurchLine and InventDim
tables.
Any ideas why that is not taking? Below is the code on the form that open
from the PO line. Please let me know if you have other methods of updating
the InventDim on a PO line. Thanks.


ttsbegin;
select forupdate localInventDim where localInventDim.inventDimId ==
purchLine.InventDimId;
if(localInventDim)
{
localInventDim.inventBatchId = formInventBatchId.text();
localInventDim.InventLocationId = formInventLocationId.text();
localInventDim.wMSLocationId = formwMSLocationId.text();
localInventDim.update();
}
ttscommit;

ttsbegin;
select forupdate localPurchLine where localPurchLine.RecId ==
purchLine.RecId;
if(localPurchLine)
{
localPurchLine.PurchReceivedNow =
any2real(formTotalFootage.valueStr());
localPurchLine.update();
}
ttscommit;

element.args().record().reread();
unknown
2008-05-15 19:26:00 UTC
Permalink
First rule in AX - you never insert/update records in InventDim yourself.

ttsbegin;
localInventDim = InventDim::find(purchLine.InventDimId);
if(localInventDim)
{
localInventDim.inventBatchId = formInventBatchId.text();
localInventDim.InventLocationId = formInventLocationId.text();
localInventDim.wMSLocationId = formwMSLocationId.text();
localInventDim = InventDim::findOrCreate(localInventDim);
}

select forupdate localPurchLine where localPurchLine.RecId ==
purchLine.RecId;
if(localPurchLine)
{
localPurchLine.InventDimId = localInventDim.InventDimId;
localPurchLine.PurchReceivedNow =
any2real(formTotalFootage.valueStr());
localPurchLine.update();
}
ttscommit;

element.args().record().reread();
--
Kashperuk Ivan (Vanya), SDET, Inventory management, Microsoft Dynamics AX
My blog - http://kashperuk.blogspot.com
Download MorphX IT in Russian - http://www.lulu.com/content/723888
Post by David Castillo
I'm trying to update a PO line from code.
I have a form that opens from the PO line passing the PO line record.
On that form, I update a location field that I want to carry over to the PO
line record.
I have code on that form to do an update of the InventDim table based on the
PO's InventDimId.
When I debugg it, it updates fine but when I refresh the PO line record, it
still has the original LocationId that was on the PurchLine and InventDim
tables.
Any ideas why that is not taking? Below is the code on the form that open
from the PO line. Please let me know if you have other methods of updating
the InventDim on a PO line. Thanks.
ttsbegin;
select forupdate localInventDim where localInventDim.inventDimId ==
purchLine.InventDimId;
if(localInventDim)
{
localInventDim.inventBatchId = formInventBatchId.text();
localInventDim.InventLocationId = formInventLocationId.text();
localInventDim.wMSLocationId = formwMSLocationId.text();
localInventDim.update();
}
ttscommit;
ttsbegin;
select forupdate localPurchLine where localPurchLine.RecId ==
purchLine.RecId;
if(localPurchLine)
{
localPurchLine.PurchReceivedNow =
any2real(formTotalFootage.valueStr());
localPurchLine.update();
}
ttscommit;
element.args().record().reread();
David Castillo
2008-05-15 19:52:01 UTC
Permalink
Vanya,
Thanks for the help. Works like a charm now.
I was not trying to insert a record. I was trying to update an existing
InventDim record though. I guess you always have to create a new one and
assing it to the PO line. Now I know better. Thanks again.
Post by unknown
First rule in AX - you never insert/update records in InventDim yourself.
ttsbegin;
localInventDim = InventDim::find(purchLine.InventDimId);
if(localInventDim)
{
localInventDim.inventBatchId = formInventBatchId.text();
localInventDim.InventLocationId = formInventLocationId.text();
localInventDim.wMSLocationId = formwMSLocationId.text();
localInventDim = InventDim::findOrCreate(localInventDim);
}
select forupdate localPurchLine where localPurchLine.RecId ==
purchLine.RecId;
if(localPurchLine)
{
localPurchLine.InventDimId = localInventDim.InventDimId;
localPurchLine.PurchReceivedNow =
any2real(formTotalFootage.valueStr());
localPurchLine.update();
}
ttscommit;
element.args().record().reread();
--
Kashperuk Ivan (Vanya), SDET, Inventory management, Microsoft Dynamics AX
My blog - http://kashperuk.blogspot.com
Download MorphX IT in Russian - http://www.lulu.com/content/723888
Post by David Castillo
I'm trying to update a PO line from code.
I have a form that opens from the PO line passing the PO line record.
On that form, I update a location field that I want to carry over to the PO
line record.
I have code on that form to do an update of the InventDim table based on the
PO's InventDimId.
When I debugg it, it updates fine but when I refresh the PO line record, it
still has the original LocationId that was on the PurchLine and InventDim
tables.
Any ideas why that is not taking? Below is the code on the form that open
from the PO line. Please let me know if you have other methods of updating
the InventDim on a PO line. Thanks.
ttsbegin;
select forupdate localInventDim where localInventDim.inventDimId ==
purchLine.InventDimId;
if(localInventDim)
{
localInventDim.inventBatchId = formInventBatchId.text();
localInventDim.InventLocationId = formInventLocationId.text();
localInventDim.wMSLocationId = formwMSLocationId.text();
localInventDim.update();
}
ttscommit;
ttsbegin;
select forupdate localPurchLine where localPurchLine.RecId ==
purchLine.RecId;
if(localPurchLine)
{
localPurchLine.PurchReceivedNow =
any2real(formTotalFootage.valueStr());
localPurchLine.update();
}
ttscommit;
element.args().record().reread();
Loading...