Solved

Sales Order - How to Restrict Copying of field (attribute) values present under USER-DEFINED FIELD tab while creating new document from existing ones

  • 10 January 2024
  • 11 replies
  • 142 views

Userlevel 4
Badge

Hi Team,

We are working with Build 23.112.0032 and have a requirement to not copy field (attribute) values present under USER-DEFINED FIELD tab while creating new document from existing ones.

 

Can you please suggest the best possible way to achieve it.

Thank you!

icon

Best answer by Vignesh Ponnusamy 17 January 2024, 21:28

View original

11 replies

Did you tried PXCopyPasteHiddenFields attribute? As per acumatica you can use this attrib in custom as well as UDF.

 

E.g. [PXCopyPasteHiddenFields(typeof(POOrderExt.usrTestField1))]

Userlevel 7
Badge +4

Hi @vivekm,

You can check the following blogpost by @Dmitrii Naumov about customizing the copy paste functionality,

https://asiablog.acumatica.com/2022/01/working-with-and-troubleshooting-copy-paste-functionality.html

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

Userlevel 4
Badge

Hi @Vignesh Ponnusamy,

Thank you for the details.

I reviewed the blogpost and went through the details. The suggested approach is working as expected for the actual DAC fields, where can restrict the certain fields copy using [PXCopyPasteHiddenFields(typeof(DAC.field))] atribute.

But under USER-DEFINED FIELD tab the fields shown are attributes and not the actual fields belongs to any DAC. So, how to restrict such attribute field value on copy action is something we are looking for. Can you help us with this please.

On using Save As Template got below information related to the USER-DEFINED FIELD attribute field.

 

Userlevel 4
Badge

Hi @amitr70 Thank you for the response.

As the field is present under USER-DEFINED FIELD tab and it is an attribute but not a custom field and is the reason I am not able to access it on extension DAC with example you shared.

E.g. [PXCopyPasteHiddenFields(typeof(POOrderExt.usrTestField1))]

POOrderExt - DAC extension of POOrder DAC

usrTestField1 - custom field.

But in my case it is an attribute ‘Color’ added under USER-DEFINED FIELD tab. Not the actual DAC field.

Userlevel 7
Badge +4

Hi @vivekm,

To access the UDFs attached to the document, you can try using cache.GetValueExt method. Following is an example statement you can try,

var AttributeAMBATLEN = Base.Document.Cache.GetValueExt(Base.Document.Current, "AttributeAMBATLEN");

I haven’t tested it yet, but I think it should work. You can try to clear the attribute value in the newly copied SO using SetValueExt method.   

Userlevel 4
Badge

Hi @Vignesh Ponnusamy ,

Thank you for the details. We will verify with the shared sample.

But having one doubt here, with the suggested sample we will get the attribute value but how we can exclude the attribute value from getting pasted to new document on copy action from existing document. Can you please suggest.

Userlevel 3
Badge

I’m looking into doing the something similar but with the copy actions on the SO301000 screen.

Could a different approach be to modify the action in the screen’s workflow to set that field to Null?

 

Userlevel 7
Badge +4

Hi @vivekm,

I’m not sure if this the ideal solution, but the below seems to work,

    public class SOOrderEntry_Extension : PXGraphExtension<PX.Objects.SO.SOOrderEntry>
{
#region Event Handlers
public delegate void CopyPasteGetScriptDelegate(Boolean isImportSimple, List<Command> script, List<Container> containers);
[PXOverride]
public void CopyPasteGetScript(Boolean isImportSimple, List<Command> script, List<Container> containers, CopyPasteGetScriptDelegate baseMethod)
{
baseMethod(isImportSimple, script, containers);
Base.Document.Cache.SetValueExt(Base.Document.Current, "AttributeAMBATLEN", null);
}
#endregion
}

Hope that helps, good luck.!

Userlevel 4
Badge

Thank you @Vignesh Ponnusamy @abrunner78 for the inputs, we will verify with shared approach.

Userlevel 4
Badge +1

Hi @vivekm 

User Defined Values will store in SOOrderKvExt Table.

You can create DAC for SOOrderKvExt and Use
 

[PXCopyPasteHiddenFields(typeof(SOOrderKvExt.usrColorField))]  code

Userlevel 4
Badge

Thank you @girik06 for the inputs, we will verify with the suggested approach.

The below approach shared by @Vignesh Ponnusamy is also working as expected.

public class SOOrderEntry_Extension : PXGraphExtension<PX.Objects.SO.SOOrderEntry> { #region Event Handlers public delegate void CopyPasteGetScriptDelegate(Boolean isImportSimple, List<Command> script, List<Container> containers); [PXOverride] public void CopyPasteGetScript(Boolean isImportSimple, List<Command> script, List<Container> containers, CopyPasteGetScriptDelegate baseMethod) { baseMethod(isImportSimple, script, containers); Base.Document.Cache.SetValueExt(Base.Document.Current, "AttributeAMBATLEN", null); } #endregion }

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