Skip to main content

I need to override a piece of Acumatica’s Approval process that prevents from Apprving a Rejected document. Not sure why Acumatica has put this control in place but it happens many times for us that a documents gets rejected to add some supporting documents and when documentation completed, then this document can be approved. The piece of the code that prevents from approving a rejected document is in EP\Descriptor\Attributes.cs as follows:

 

        public virtual bool Approve(SourceAssign source)
        {
            EPApproval item = (EPApproval)this._Rejected.SelectSingle(GetSourceNoteID(source));

            if (item != null)
                throw new PXException(Messages.CannotApproveRejectedItem);

            if (UpdateApproval(source, EPApprovalStatus.Approved))
            {
                RegisterActivity(source, PO.Messages.Approved);

                return true;
            }

            return false;
        }

Hi, Do you have any solution for this ?. 


Hi, If you need to override this method, you could use this syntax:

 

>PXOverride]

public virtual bool Approve(SourceAssign source, Func<SourceAssign, bool> baseMethod)

{

// do your staff, code logic

// invoke base Acumatica’s method

bool returnBoolValue = baseMethod(source);

if (returnBoolValue == true)

   {

       // do your staff

   }

}


thanks, @andriikravetskyi35 , and hi @arun83 @Chris Hackett 

with the above syntax, the base method will be called first I guess by the framework not the overridden one. In fact, I am not sure if the overridden method will be called at all. I believe the correct syntax is as follows. @arun83 please test to see which one will work best in your case.

gPXOverride]
public override bool Approve(SourceAssign source)
{
// Do Stuff Here

// Invoke Acumatica’s base method or simply do not call it if you don't need it.
bool baseValue = base.Approve(source);

// Do Stuff Here

return ?;
}

 


Reply