Skip to main content

Hello Gang,

As you may have noticed there is a logcal issue in Acumatica’s Approval Map Workflow injection to the Document workflow. In document worflow if an action is not allowed, its buttom is hidden but in Approval Map WF, the “Approve” & “Reject” buttons are always visible whether or not that user is an authorized approver. When user clicks on Approve/Reject then if not an authorized user, receives an error that “You are not an authorized approver!” What I want to do is to hide the Approve/Reject if the user is not an authorized approver. Here is my code. I do not get any error but the buttons are always visible. What I’m doing wrong?

 

       protected virtual void APInvoice_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
APInvoiceEntry_ApprovalWorkflow graphExt = Base.GetExtension<APInvoiceEntry_ApprovalWorkflow>();

APInvoice document = Base.Document.Current;

EPApproval approval = PXSelect<EPApproval,
Where<EPApproval.refNoteID, Equal<Required<EPApproval.refNoteID>>,
And<EPApproval.status, Equal<Required<EPApproval.status>>,
And<EPApproval.ownerID, Equal<Required<EPApproval.ownerID>>>>>,
OrderBy<Asc<EPApproval.approvalID>>>
.Select(Base, document.NoteID, EPStatuses.Pending, Base.Accessinfo.ContactID).FirstOrDefault();

bool Visible = (approval != null) ? true : false;

graphExt.approve.SetVisible(Visible);
graphExt.reject.SetVisible(Visible);
}

 

Try this:

protected virtual void _(Events.RowSelected<APInvoice> e)
{
var apInvoiceGraph = e.Cache.Graph as APInvoiceEntry;
var apInvoiceApprovalGraph = apInvoiceGraph.GetExtension<APInvoiceEntry_ApprovalWorkflow>();

APInvoice document = apInvoiceGraph.Document.Current;

EPApproval approval = SelectFrom<EPApproval>.
Where<EPApproval.refNoteID.IsEqual<@P.AsGuid>.
And<EPApproval.status.IsEqual<EPApprovalStatus.pending>>.
And<EPApproval.ownerID.IsEqual<@P.AsInt>>>.View.
SelectWindowed(apInvoiceGraph, 0, 1, document.NoteID, Base.Accessinfo.ContactID);

apInvoiceApprovalGraph.approve.SetVisible(approval is object);
apInvoiceApprovalGraph.reject.SetVisible(approval is object);
}

 


Thanks @darylbowman 

I tested your code and the result is as same as mine. Show /Hide doesn’t work.


What version are you on? It works for me in 21 R2


@darylbowman 21R2 same here


Does it not show or not hide?


@darylbowman doesn’t hide


Maybe try unpublishing and republishing? Here’s a customization project.


@darylbowman Thank you. The problem is not resolved. Do you have approval map set up? 


I do. I checked with a user that has permission and one that does not. The buttons disappear for the one who does not, and appear for the one who does.


@darylbowman Not sure why it doesn’t work for me. It is srange that with the same logic in my code, “SetEnabled” works but “SetVisible” doesn’t. 


Could it be something with your approval map? Do you mind sharing a screenshot of it?


 Hi @aaghaei were you able to resolve your issue? Thank you!


hi @darylbowman We just use out of the box workflow. We have not touched it.

 

@Chris Hackett thanks for the follow up. No, I couldn’t figure it out.


UPDATE

@darylbowman @Chris Hackett 

Finally I figured out what is happening. The case is if we add the actions to our favorites by staring (*) them, Acumatica will then adds them to “FavoriteActionRecord” table. It appears actions added to this table, overrides the Show/Hide in RowSelected event handler. When I remove the Star from actions, everything works just fine. When I star then system shows the action buttons on my screen all the time even if I try to hide them through an event handler.


Reply