0
votes

How to hide a field while copy and past. The field is part of the extension of the sales order.DAC.

I have tried [PXCopyPasteHiddenFields(typeof(PSSOOrderExtNV.usrIsInHandsDate))] and I am getting the following compilation error.

Error CS0592 Attribute 'PXCopyPasteHiddenFields' is not valid on this declaration type. It is only valid on 'class, field' declarations.

I have tried to Override the method CopyPasteGetScript I did not get the desired result.

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);
        SOOrder order = Base.Document.Current;
        if(Base.Document.Cache.GetStatus(order) == PXEntryStatus.Inserted)
        {
            PSSOOrderExtNV extn = PXCache<SOOrder>.GetExtension<PSSOOrderExtNV>(order);
            extn.UsrHoldUntil = null;
            extn.UsrReadyforProductionapproval = null;
            extn.UsrReadyForProduction = null;
            extn.UsrIsOrdered = null;
            extn.UsrIsAllocated = null;
            extn.UsrEmbPaperReceived = null;
            extn.UsrEmbGoodsReceived = null;
            extn.UsrWorksheetPrinted = null;
            extn.UsrGoodsOnCarts = null;
            Base.Document.Update(order);
        }
    }

Update

I have modified the code as bellow in graph extension of SOOrderEntry. It is not giving error while compiling, but it is copying the values to new order.

        [PXCopyPasteHiddenFields(typeof(SOOrder.cancelled), typeof(SOOrder.preAuthTranNumber), typeof(SOOrder.ownerID), typeof(SOOrder.workgroupID), 
                             typeof(PSSOOrderExtNV.usrHoldUntil),typeof(PSSOOrderExtNV.usrReadyForProduction),typeof(PSSOOrderExtNV.usrReadyforProductionapproval),typeof(PSSOOrderExtNV.usrIsOrdered),
                             typeof(PSSOOrderExtNV.usrIsAllocated),typeof(PSSOOrderExtNV.usrEmbPaperReceived),typeof(PSSOOrderExtNV.usrEmbGoodsReceived),typeof(PSSOOrderExtNV.usrWorksheetPrinted),
                             typeof(PSSOOrderExtNV.usrGoodsOnCarts))]
    public PXSelect<SOOrder, Where<SOOrder.orderType, Equal<Current<SOOrder.orderType>>, And<SOOrder.orderNbr, Equal<Current<SOOrder.orderNbr>>>>> CurrentDocument;
1
Putting the attribute on a DataView is definitely an improvement. As for why fields are still copied, is PSSOOrderExtNV a direct extension on SOOrder declared as class PSSOOrderExtNV : PXCacheExtension<SOOrder> ?Hugues Beauséjour

1 Answers

0
votes

PXCopyPasteHiddenFields attribute typically decorates DataViews.

This example in Sales Order graph, hides the SOLine.Completed field from the Transactions DataView:

[PXViewName(Messages.SOLine)]
[PXImport(typeof(SOOrder))]
[PXCopyPasteHiddenFields(typeof(SOLine.completed))]
public PXOrderedSelect<SOOrder, SOLine,
    Where<SOLine.orderType, Equal<Current<SOOrder.orderType>>,
        And<SOLine.orderNbr, Equal<Current<SOOrder.orderNbr>>>>,
    OrderBy<Asc<SOLine.orderType, Asc<SOLine.orderNbr, Asc<SOLine.sortOrder, Asc<SOLine.lineNbr>>>>>> Transactions;