How to disable a standard button

I am using the following C# code to disable a standard button during form load.

EpiButton ctrl = (EpiButton)csm.GetNativeControlReference(“32da3a44-bd26-454a-9376-e0f9ddde1e4b”);
ctrl.Enabled = false;
ctrl.Visible = false;

This code works in other forms for the referenced EpiGuid of the button.

However, in this form the Guid is different each time the form loads.
Error Detail

Message: Exception has been thrown by the target of an invocation.
Inner Exception Message: Control with specified EpiGuid property does not exist.

csm.GetNativeControlReference(“32da3a44-bd26-454a-9376-e0f9ddde1e4b”)
Program: CommonLanguageRuntimeLibrary
Method: InvokeMethod

Is there another method to disabling a standard button?

Have you tried doing in under Properties tab and not in the script?

No. But the reason being, I am disabling the button based on the security group assigned to the login user session. This works just fine in many other screen, but not from the Sales workbench. Very odd.

Which button are you trying to disable in Sales Workbench?

Sales Management > Customer Relationship Management > General Operations > Salesperson Workbench screen > Orders tab> Open tab> Add button.

Note, I am able to disable the Order tab> By customer> Add button using the EpiGuid method:

EpiButton ctrl = (EpiButton)csm.GetNativeControlReference(“32da3a44-bd26-454a-9376-e0f9ddde1e4b”);
ctrl.Enabled = false;
ctrl.Visible = false;

I noticed that the EpiGuid for the button changes each time:

1.Turn customization mode on.
2.Open Sales workbench
3.Select Tools> Customizations
4.Click on the Orders tab, Open tab and Add button.
5.Note the EpiGuid value
6.Exit customization do not save anything.
7.Exist the form
8.Repeat steps 2 - 7

Can you just do a BPM on whatever method the button uses to throw an error when someone who shouldn’t be clicking clicks?

You could loop the controls on the form and when you come across that button then disable it.

Interesting - is this a runtime dashboard? If so, that’s your problem. You’ll need to compile it to an assembly (Deploy) - then you’d do your customizations.

Yes, and thank you.

1 Like

Excellent - throw me a solution then - I haven’t got one all year :smiley:

2 Likes

Its only Jan 12th! I will do my best (if I understand your hint). Otherwise, please let me know what you mean?

I mean if my suggestion about compiling your dashboard solved this problem, mark it as the solution (with the checkbox under the post)

I will test this over the weekend to make sure.

Thanks