Skip to main content

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!

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

 

E.g. gPXCopyPasteHiddenFields(typeof(POOrderExt.usrTestField1))]


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.!


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.

 


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.


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.   


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.


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?

 


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.!


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


Hi @vivekm 

User Defined Values will store in SOOrderKvExt Table.

You can create DAC for SOOrderKvExt and Use
 

ePXCopyPasteHiddenFields(typeof(SOOrderKvExt.usrColorField))]  code


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