Solved

Button Show/Hide doesn't work


Userlevel 7
Badge +9

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);
}

 

icon

Best answer by aaghaei 19 July 2022, 23:27

View original

14 replies

Badge +11

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);
}

 

Userlevel 7
Badge +9

Thanks @darylbowman 

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

Badge +11

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

Userlevel 7
Badge +9

@darylbowman 21R2 same here

Badge +11

Does it not show or not hide?

Userlevel 7
Badge +9

@darylbowman doesn’t hide

Badge +11

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

Userlevel 7
Badge +9

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

Badge +11

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.

Userlevel 7
Badge +9

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

Badge +11

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

Userlevel 7
Badge

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

Userlevel 7
Badge +9

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.

Userlevel 7
Badge +9

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


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