Skip to main content
Solved

UPDATE INVENTORY

  • Nov 3, 2021 12:57 AM UTC
  • 6 replies
  • 686 views
  • Translate All

Forum|alt.badge.img

Hello Acumatica Friends :) 

 

I have a question regarding the Update Inventory in Shipement. We want to do it with code for specific shipments (say a condition on the Customer ID) 

 

Is this possible ? I know we tried this function (

soShipmentGraph.UpdateIN.PressButton ()) It changes the shipement status but the inventory is not updated. We don’t have the 2 step-transfer (IN3040PL).

 

In desperate need for help; plzzzz

 

Thank you. 

Best answer by markusray17

    public class SOShipmentEntryExt: PXGraphExtension<SOShipmentEntry>
{
public static bool IsActive() => true;

[PXOverride]
public IEnumerable ConfirmShipmentAction(PXAdapter adapter)
{
Base.confirmShipmentAction.Press(adapter);

PXLongOperation.WaitCompletion(Base.UID);

Base.SelectTimeStamp();

if (Base.Document.Current.ShipmentType == SOShipmentType.Transfer)
Base.UpdateIN.Press();

return adapter.Get();
}
}

I actually had a similar project on my list to work on and got the above code to work as intended. I added the WaitCompletion() call because I was getting an error that the previous operation was not finished when calling Base.UpdateIN.Press(). The Base.SelectTimeStamp() call just updates the graph’s timestamp so you don’t get an error when the UpdateIN action attempts to persist records. 

View original

6 replies

Forum|alt.badge.img+5
  • Jr Varsity II
  • Nov 3, 2021 3:34 PM UTC

When and where did you want to do this? As in did you want it to automatically update Inventory when the shipment is confirmed based on this condition, or maybe you want a processing page that can be automated to update inventory on all shipments meeting this condition?

 

If calling the UpdateIN action from the graph isn’t working properly I would check the trace log, I would think that means something errored when creating/releasing the matching inventory transactions.

Translate

Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • Nov 3, 2021 4:27 PM UTC

Hello 

 

Thank you @markusray17 

Yes, we want to update inventory when the shipment is confirmed. 

I don’t think we found anything when checking the trace though :/ 

Translate

Forum|alt.badge.img+5
  • Jr Varsity II
  • Nov 3, 2021 4:30 PM UTC

Do you have a code snippet to share? Presumably you are adding the call to UpdateIN after the ConfirmShipment action? 

Translate

Forum|alt.badge.img+5
  • Jr Varsity II
  • Answer
  • Nov 3, 2021 9:59 PM UTC
    public class SOShipmentEntryExt: PXGraphExtension<SOShipmentEntry>
{
public static bool IsActive() => true;

[PXOverride]
public IEnumerable ConfirmShipmentAction(PXAdapter adapter)
{
Base.confirmShipmentAction.Press(adapter);

PXLongOperation.WaitCompletion(Base.UID);

Base.SelectTimeStamp();

if (Base.Document.Current.ShipmentType == SOShipmentType.Transfer)
Base.UpdateIN.Press();

return adapter.Get();
}
}

I actually had a similar project on my list to work on and got the above code to work as intended. I added the WaitCompletion() call because I was getting an error that the previous operation was not finished when calling Base.UpdateIN.Press(). The Base.SelectTimeStamp() call just updates the graph’s timestamp so you don’t get an error when the UpdateIN action attempts to persist records. 

Translate

Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • Nov 4, 2021 8:21 AM UTC

Hello @markusray17 

 

It works!! Thank you so much for you help;

My code was missing Base.SelectTimeStamp()

 

:)) 

Translate

mvolshteyn
Acumatica Moderator
Forum|alt.badge.img+3
  • Technical Account Manager in the ISV Team
  • Nov 5, 2021 11:50 AM UTC
    public class SOShipmentEntryExt: PXGraphExtension<SOShipmentEntry>
{
public static bool IsActive() => true;

[PXOverride]
public IEnumerable ConfirmShipmentAction(PXAdapter adapter)
{
Base.confirmShipmentAction.Press(adapter);

PXLongOperation.WaitCompletion(Base.UID);

Base.SelectTimeStamp();

if (Base.Document.Current.ShipmentType == SOShipmentType.Transfer)
Base.UpdateIN.Press();

return adapter.Get();
}
}

I actually had a similar project on my list to work on and got the above code to work as intended. I added the WaitCompletion() call because I was getting an error that the previous operation was not finished when calling Base.UpdateIN.Press(). The Base.SelectTimeStamp() call just updates the graph’s timestamp so you don’t get an error when the UpdateIN action attempts to persist records. 

@markusray17 , @NAWRES , I believe it shoul be mentioned that this approach works well only since  relatively recent  versions of 2020R2 and 2021R1 (I believe after 20.214 and 21.111). Before these updates, this custom code leaves transfer shipments in the Open status instead of Completed (and probably is vulnerable to otherr problems, since it semmed to run the Update In action on an unconfirmed shipment even if shipment confirmation failed)

Translate