Solved

Copying User Defined Fields acrross the sales order, shipment and invoice screen

  • 3 January 2024
  • 15 replies
  • 350 views

Userlevel 1

Does anyone have a solution on how we can copy user-defined fields values across these screens when we create a shipment from a sales order and an invoice from the shipment?

icon

Best answer by Vignesh Ponnusamy 5 January 2024, 17:41

View original

15 replies

Userlevel 7
Badge +12

Hi @Aldrin 

Did you verify the below suggestions

 

Userlevel 7
Badge +18

@Aldrin Additionally, you can also review the below link as well.

 

Userlevel 1

I did with the first one and It did not work, I am not looking for the the one that copies custom fields but rather UDF which you define on the screen with attributes

Userlevel 7
Badge +4

Hi @Aldrin,

As suggest by fellow community members, you can use PXGraph.InstanceCreated.AddHandler within which you can set the UDF value in the RowPersisting event. 

Within row persisting event, you can use Cache.GetValueExt and Cache.SetValueExt method to fetch the value and set the value of the UDF. Below is an example implementation you can reference,

 public class SOOrderEntry_Extension : PXGraphExtension<PX.Objects.SO.SOOrderEntry>
{
#region Event Handlers
public delegate IEnumerable CreateShipmentIssueDelegate(PXAdapter adapter, Nullable<DateTime> shipDate, Nullable<Int32> siteID);
[PXOverride]
public IEnumerable CreateShipmentIssue(PXAdapter adapter, Nullable<DateTime> shipDate, Nullable<Int32> siteID, CreateShipmentIssueDelegate baseMethod)
{
PXGraph.InstanceCreated.AddHandler<SOShipmentEntry>((graphShipmentEntry) =>
{
graphShipmentEntry.RowPersisting.AddHandler<SOShipment>((sender, e) =>
{
var AttributeAMBATLEN = Base.Document.Cache.GetValueExt(Base.Document.Current, "AttributeAMBATLEN");
graphShipmentEntry.Document.Cache.SetValueExt(graphShipmentEntry.Document.Current, "AttributeAMBATLEN", AttributeAMBATLEN.ToString());
});
});
return baseMethod(adapter,shipDate,siteID);
}
#endregion
}

I have also attached the customization package, which copies the AMBATLEN attribute from SO → Shipment → Invoice.

Note: In GetValueExt and SetValueExt, you need to prefix the attribute id with Attribute

Feel free to post if you have any questions. Good Luck,

Userlevel 1

This worked perfectly thank you very much. And the attribute prefix was a missing link I was using the usr prefix.

Userlevel 1

Does anyone have a solution on how we can copy user-defined fields values across these screens when we create a shipment from a sales order and an invoice from the shipment?

This answer worked from transactions that goes through the process from sales order to shipment to invoice. For transactions that does not require shipment that goes from sales order to invoice it's not copying. How can I modify the code to accommodate this

Userlevel 1

Hi @Aldrin,

As suggest by fellow community members, you can use PXGraph.InstanceCreated.AddHandler within which you can set the UDF value in the RowPersisting event. 

Within row persisting event, you can use Cache.GetValueExt and Cache.SetValueExt method to fetch the value and set the value of the UDF. Below is an example implementation you can reference,

 public class SOOrderEntry_Extension : PXGraphExtension<PX.Objects.SO.SOOrderEntry>
{
#region Event Handlers
public delegate IEnumerable CreateShipmentIssueDelegate(PXAdapter adapter, Nullable<DateTime> shipDate, Nullable<Int32> siteID);
[PXOverride]
public IEnumerable CreateShipmentIssue(PXAdapter adapter, Nullable<DateTime> shipDate, Nullable<Int32> siteID, CreateShipmentIssueDelegate baseMethod)
{
PXGraph.InstanceCreated.AddHandler<SOShipmentEntry>((graphShipmentEntry) =>
{
graphShipmentEntry.RowPersisting.AddHandler<SOShipment>((sender, e) =>
{
var AttributeAMBATLEN = Base.Document.Cache.GetValueExt(Base.Document.Current, "AttributeAMBATLEN");
graphShipmentEntry.Document.Cache.SetValueExt(graphShipmentEntry.Document.Current, "AttributeAMBATLEN", AttributeAMBATLEN.ToString());
});
});
return baseMethod(adapter,shipDate,siteID);
}
#endregion
}

I have also attached the customization package, which copies the AMBATLEN attribute from SO → Shipment → Invoice.

Note: In GetValueExt and SetValueExt, you need to prefix the attribute id with Attribute

Feel free to post if you have any questions. Good Luck,

This answer worked from transactions that goes through the process from sales order to shipment to invoice. For transactions that does not require shipment that goes from sales order to invoice it's not copying. How can I modify the code to accommodate this

Userlevel 7
Badge +4

Hi @Aldrin,

You can override the PrepareInvoice action in the SOOrderEntry. Following thread has an example,

Note: You modify the example to copy the UDF instead of custom fields. Feel free to post if you have any questions. Good Luck,

Userlevel 1

Hi @Aldrin,

You can override the PrepareInvoice action in the SOOrderEntry. Following thread has an example,

Note: You modify the example to copy the UDF instead of custom fields. Feel free to post if you have any questions. Good Luck,

I am fairly new to Acumatica development I am struggling to override the Prepare Invoice action while at the same time maintaining the original code that copies my UDF Can you or someone please kindly modify the D20963 customization package that you sent so that it accommodates instances where the item does not require shipment, going straight from SO to invoice?

Userlevel 7
Badge +4

Hi @Aldrin,

Sure, I have attached the updated customization package for your reference. Good Luck,

 

Userlevel 1

Hi @Aldrin,

Sure, I have attached the updated customization package for your reference. Good Luck,

 

Thanks, I have managed to replicate the example in my solution, and it worked.😊

Userlevel 1

Hi @Aldrin,

Sure, I have attached the updated customization package for your reference. Good Luck,

 

Hi Vignesh have you noticed that if the attribute is a dropdown (combo) it doesn't copy? But all the other control types are copying perfectly.

Or is there a way in which we need to declare it in the code?

 

Userlevel 1

I have figured out that the value ID needs to be equal to the Description for it to copy if not It won’t. Is there a way to resolve this?

 

Userlevel 7
Badge +4

Hi @Aldrin,

For the Combo control type attribute, try like below,

var AttributeAMBATCOLOR = (PXStringState)Base.Document.Cache.GetValueExt(Base.Document.Current, "AttributeAMBATCOLOR");
graphShipmentEntry.Document.Cache.SetValueExt(graphShipmentEntry.Document.Current, "AttributeAMBATCOLOR", AttributeAMBATCOLOR.Value);

TypeCast the GetValueExt PXStringState, then use Value to get the value of the selected combo value.

Hope that helps.! Feel free to post if you have any questions.! Good Luck,

I bHi @Aldrin,

For the Combo control type attribute, try like below,

var AttributeAMBATCOLOR = (PXStringState)Base.Document.Cache.GetValueExt(Base.Document.Current, "AttributeAMBATCOLOR");
graphShipmentEntry.Document.Cache.SetValueExt(graphShipmentEntry.Document.Current, "AttributeAMBATCOLOR", AttributeAMBATCOLOR.Value);

TypeCast the GetValueExt PXStringState, then use Value to get the value of the selected combo value.

Hope that helps.! Feel free to post if you have any questions.! Good Luck,

Hi team, I have another tricky one A client has custom fields (not User defined fields) on the issues screen on the summary area. The same fields exists on the SO invoice screen on the summary area. The fields needs to be copied from the invoice to the issues screen for the issue that is created in the back ground when you release the SO invoice. Which method should I be overriding and how. Its slightly different from the above because the action would take you to the next screen etc

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