Solved

How to set the owner of a shipment to whomever clicked the Create Shipment button in a Sales Order

  • 28 February 2024
  • 1 reply
  • 46 views

I am trying to set the Owner field in a shipment to whomever clicked the Create Shipment button on the Sales Order that the shipment is related to.  Scoured the web but I am unable to find anything related to this and I am new to Acumatica in general.  Any help is appreciated. 

icon

Best answer by Zoltan Febert 29 February 2024, 02:52

View original

1 reply

Userlevel 6
Badge +3

Hi @kevinwedemeier,

You need to override SetShipmentFieldsFromOrder function in SOShipmentEntry.
Owner is a Contact, so once you have the UserID, you can get ContactID from Contact table.

using System;
using PX.Data;
using PX.Data.BQL;
using PX.Data.BQL.Fluent;
using PX.Objects.CR;

namespace PX.Objects.SO
{
// Acuminator disable once PX1016 ExtensionDoesNotDeclareIsActiveMethod extension should be constantly active
public class SOShipmentEntryExt : PXGraphExtension<SOShipmentEntry>
{
[InjectDependency]
public ICurrentUserInformationProvider UserInformationProvider { get; set; }

[PXOverride]
public virtual bool SetShipmentFieldsFromOrder(
SOOrder order,
SOShipment shipment,
int? siteID,
DateTime? shipDate,
string operation,
SOOrderTypeOperation orderOperation,
bool newlyCreated,
Func<SOOrder, SOShipment, int?, DateTime?, string, SOOrderTypeOperation, bool, bool> baseMethod)
{
var contact = (Contact)SelectFrom<Contact>
.Where<Contact.userID.IsEqual<@P.AsGuid>>
.View.Select(Base, UserInformationProvider.GetUserId());
shipment.OwnerID = contact?.ContactID;

return baseMethod(order, shipment, siteID, shipDate, operation, orderOperation, newlyCreated);
}
}
}

 

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved