Is there a way to make an action in Count Cycle read only?

Hello,

I was asked by a manager if I could make the ‘Cancel Cycle’ in the Actions menu be read only to everyone but certain people? Or just read only to everyone if that is not possible?

I have no idea if it is even possible so I thought I would ask here.

Any help is appreciated.

Thanks,
Shawn

OK,

I have found the Name of the toolClick. It is ‘CancelPI’.
I have got it the do a message pop-up.
If I can figure out how to cancel the rest of the actions associated with the click, I will be happy with that.

Anybody have any ideas?

Thanks in advance,
Shawn

A few options:

Replace that menu item with your own. In the case you can do what you want, prompt a password or allow based on user etc.

Simply disable the menu item. Something like this

ButtonTool CancelPI = (ButtonTool)YourForm.MainToolManager.Tools["CancelPI"];
CancelPI.SharedProps.Visible = false;
1 Like

Why is there a + after the ;?
Also, where do I put this? under InitializeCustomCode()?

Typo. I’d put it in the FormLoad just to make sure everything is initialized. But it would probably also work in Initialize

I am getting:
Error: CS0246 - line 58 (145) - The type or namespace name ‘ButtonTool’ could not be found (are you missing a using directive or an assembly reference?)
Error: CS0246 - line 58 (145) - The type or namespace name ‘ButtonTool’ could not be found (are you missing a using directive or an assembly reference?)

Any ideas?

using Infragistics.Win.UltraWinToolbars;

2 Likes

Thanks!

That hid the menu option.

Now my question is, When my manager needs the option, How do I bring it back for him only?

I know I can create a copy of the menu item and not apply the customization to it, but wasn’t sure if that was the best way to go about it?

I really appreciate all the help you are giving me. It is a lifesaver!

Thanks,
Shawn

Your idea is the easiest way - just make a menu item without the customization just for your manager. Or…I suppose you could check the user before calling your function above - if it’s Mr. Manager, don’t run that line.

How would you check the manager?

I am assuming with an if statement. What is the correct way to find the Session.UserID?

Hey,

I puzzled it out.

It is working great. Thanks to @Chris_Conn for all his help. He is THE MAN!!!

2 Likes

For future reference to anyone who wants to do something like this:

In script Editor:
At the top, I added:

using Infragistics.Win.UltraWinToolbars;
using Ice.Core;

Then at the bottom, I added this (before the last close curly bracket):

private void CountCycleForm_Load(object sender, EventArgs args) //Change CountCycleForm to your form name.
{
	// Add Event Handler Code
	Ice.Core.Session session = (Ice.Core.Session) 
	CountCycleForm.Session; 
	string PN = session.UserID; 
	
	if(PN == "Example_User"){ //PN = "Your User ID HERE"
		//This lets you keep the ToolButton item visible.
	}else{
        //Change CountCycleForm to your form name. Change CancelPI to the item name.
		ButtonTool CancelPI = (ButtonTool)CountCycleForm.MainToolManager.Tools["CancelPI"]; 
		CancelPI.SharedProps.Visible = false;
	}
}

Hope this helps someone in the future.
Again, thanks to @Chris_Conn for helping me put this together.

Here’s a document I put together on how the find the item name. I got it from another website and referenced it in the footer.
Find out what a click event name is.docx (134.3 KB)

3 Likes

Nice, taking the bull by the horns. Way to piece it all together for your solution - and thanks for the praise, that and mountain dew keep me fueled :smile:

I would suggest using a security group instead of hard coding the username that will have access. I use the following code to check the user security group.

private void CheckUserIdSecGrp()
{

	// Get the Current User ID from the Call Context Client data set.
    EpiDataView edv = (EpiDataView) this.oTrans.EpiDataViews["CallContextClientData"];
    string myuser = edv.dataView[0]["CurrentUserId"].ToString();
    try
    {   //need to bring in userfileadapter as well via import bl assemblies to get this reference
        UserFileAdapter adapterUserFile = new UserFileAdapter(this.oTrans);

        adapterUserFile.BOConnect();
        bool result = adapterUserFile.GetByID(myuser); 
		// Get the dataset by the login User session id. GetByID. Returns a DataSet given the primary key. 

        if (result == true)
        {
            if (adapterUserFile.UserFileData.UserFile[0]["SecurityMgr"].ToString() == "True" ||
                adapterUserFile.UserFileData.UserFile[0]["GroupList"].ToString().IndexOf("CREATESALEORDER") != -1) // The security group name (code id). 

            {
                fullversion = true; // fullversion should be declared at form initialization as Boolean and set to false. 
            }
        }
        // Cleanup Adapter Reference
        adapterUserFile.Dispose();
    }
    catch (System.Exception ex)
    {
        ExceptionBox.Show(ex);
    }
}

// Enjoy

2 Likes

You will need the following assemblies and BOs.

Ice.Contracts.BO.UserFile

Also include:
using Ice.BO
using Ice.Adapters
using Erp.Adapters

What do you mean by this? Should it be a using? I am not familiar enough to quite catch it.

"You will need the following assemblies and BOs.

Ice.Contracts.BO.UserFile"

Nevermind, I finally worked through it.
I am adding your your because it is easier to manager with a group.

Thank you to both of you for all the help @asmar and @Chris_Conn!

I super appreciate it!

OK,

I type up a document that goes through what I did to create this. I am uploading it below for the future.

Thank you to both @Chris_Conn and @asmar for helping me put this together.

Thanks,

Shawn
Hide a Menu Item Conditional Ver 2 Using Security Groups.docx (17.5 KB)

3 Likes