Disable Printer Icon until User applies filter

Good Morning,

First off, WTH Epicor doesn’t make it less likely for users to NOT print the entire company’s BOMs is beyond my comprehension. Ok, gripe over…

We have a few reports, BOMs particularly that require a filter before user goes to print. It has recently come to our attention that the customization setting .Enabled = False on the PrintTool is not working. (Came to attention after user accidentally printed 900 pages of BOMs before being told by coworker that he was hogging the printer! :frowning:)

What’s really strange about it is that the PrintPreviewTool and GenerateTool are disabled as expected but not the PrintTool. Looking into the code available tools I saw additional PrintServerTool and PrintClientTool, but they don’t disable them either. As a matter of fact they don’t even exist during the code run.

I really hate to have to redo the whole way we do this. Any suggestions on how to make this work?

Thanks!
Nancy

The obvious difference between the ones that disable and the one that doesn’t, is that the problem one is a dropdown. They behave a bit differently, and I suspect that’s the root of your troubles.

I think you can disable to tool in the drop down via ClientPrintTool and SeverPrintTool, but you can do an AfterToolClick with a message box showing the key to find out for sure.

Otherwise, the way I have done it in the past is a check of the filter dataset when any of the tools are clicked and do an args.Cancel if empty.

Thanks for your replies.

I used msgbox to get the name of the tool and they are PrintPreviewTool and PrintClientTool. Doing the normal .enabled = false doesn’t work.

I think Daryl is right in that it behaves differently for this drop down. I suspect we will need to go your way Aaron, with new means of checking for filter upon tool click instead.

Nancy

I’ve done a before click event that cancels the event when there is not a value in one of my baq report filters. You might be able to do the same thing…

private void BAQReportForm_BeforeToolClick(object sender, Ice.Lib.Framework.BeforeToolClickEventArgs args)
	{
				//EpiMessageBox.Show(args.Tool.Key);
		/*INSERT IF STATEMENTS HERE the arg.Tool.Key is the tool that was clicked. you can check the value of your filter and then if it is blank you can write: throw new UIException("YOUR MESSAGE HERE.") */

	}
2 Likes

There are a few ways you can do it, but just like @utaylor on a Report I kept it simple and just did like he did.

private void BAQReportForm_BeforeToolClick(object sender, Ice.Lib.Framework.BeforeToolClickEventArgs args)
{
	switch (args.Tool.Key)
	{
		case "PrintClientTool":
		case "PrintServerTool":
		case "PrintPreviewTool":
			// Build whereClause so we can inspect it
			string whereClause = this.buildBatchesWhereClause();

			if (whereClause == string.Empty)
			{
				args.Handled = true;
				EpiMessageBox.Show("You Must Select Filters, Unable to Print Wide Open.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
			}

			if (args.Tool.Key != "PrintPreviewTool" && this.IsWatermarkEnabled())
			{
				args.Handled = true;
				EpiMessageBox.Show("Something...", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
			}
			break;
	}

}

The other way is to do it on EpiViewNotification and always apply the Enabled/Disabled to the Tool

2 Likes

I believe I got the idea from you or someone else on the forum. It seems to work pretty well!

Sometimes with the toolbar icons you enter a race condition with something Epicor is doing in their logic. Typically your initialize code that would disable it fires, then a binding of some sorts of theirs after the data views become available enables them again leaving you sad.