Skip to main content
Answer

Button Show/Hide doesn't work

  • April 13, 2022
  • 14 replies
  • 350 views

aaghaei
Captain II
Forum|alt.badge.img+10

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

 

Best answer by aaghaei

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.

14 replies

darylbowman
Captain II
Forum|alt.badge.img+15

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

 


aaghaei
Captain II
Forum|alt.badge.img+10
  • Author
  • Captain II
  • April 13, 2022

Thanks @darylbowman 

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


darylbowman
Captain II
Forum|alt.badge.img+15

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


aaghaei
Captain II
Forum|alt.badge.img+10
  • Author
  • Captain II
  • April 13, 2022

@darylbowman 21R2 same here


darylbowman
Captain II
Forum|alt.badge.img+15

Does it not show or not hide?


aaghaei
Captain II
Forum|alt.badge.img+10
  • Author
  • Captain II
  • April 13, 2022

@darylbowman doesn’t hide


darylbowman
Captain II
Forum|alt.badge.img+15

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


aaghaei
Captain II
Forum|alt.badge.img+10
  • Author
  • Captain II
  • April 13, 2022

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


darylbowman
Captain II
Forum|alt.badge.img+15

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.


aaghaei
Captain II
Forum|alt.badge.img+10
  • Author
  • Captain II
  • April 13, 2022

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


darylbowman
Captain II
Forum|alt.badge.img+15

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


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • April 26, 2022

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


aaghaei
Captain II
Forum|alt.badge.img+10
  • Author
  • Captain II
  • April 28, 2022

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.


aaghaei
Captain II
Forum|alt.badge.img+10
  • Author
  • Captain II
  • Answer
  • July 19, 2022

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.