Adding Change Log button to DMR Processing Toolbar

I am tracking changes to DMR Head and I have setup a BAM to create a log. Next I am trying to get the Change Log button to show up on the DMR Processing from. I have added the code below but get the following error when I launch the form:

image

Here is my code:

// **************************************************
// Custom code for DMRProcessingForm
// Created: 11/20/2018 6:00:41 PM
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Epicor.Mfg.BO;
using Epicor.Mfg.UI;
using Epicor.Mfg.UI.Adapters;
using Epicor.Mfg.UI.Customization;
using Epicor.Mfg.UI.ExtendedProps;
using Epicor.Mfg.UI.FormFunctions;
using Epicor.Mfg.UI.FrameWork;
using Epicor.Mfg.UI.Searches;
using Infragistics.Win.UltraWinToolbars;

public class Script
{
	// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
	// Begin Wizard Added Module Level Variables **

	// End Wizard Added Module Level Variables **

	// Add Custom Module Level Variables Here **
	private EpiDataView edvDMRHead;
	private ButtonTool _btlChgLog;

	public void InitializeCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
		// Begin Wizard Added Variable Initialization

		this.edvDMRHead = ((EpiDataView)(this.oTrans.EpiDataViews["DMRHead"]));
		this.edvDMRHead.EpiViewNotification += new EpiViewNotification(this.edvDMRHead_EpiViewNotification);
		this.baseToolbarsManager.ToolClick += new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(this.baseToolbarsManager_ToolClick);
		// End Wizard Added Variable Initialization

		// Begin Wizard Added Custom Method Calls

		// End Wizard Added Custom Method Calls
	}

	public void DestroyCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
		// Begin Wizard Added Object Disposal

		this.edvDMRHead.EpiViewNotification -= new EpiViewNotification(this.edvDMRHead_EpiViewNotification);
		this.edvDMRHead = null;
		this.baseToolbarsManager.ToolClick -= new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(this.baseToolbarsManager_ToolClick);
		this._btlChgLog.Dispose();
		this._btlChgLog = null;
		// End Wizard Added Object Disposal

		// Begin Custom Code Disposal

		// End Custom Code Disposal
	}
	private void AddChgLogButton()
	{
    	if (!baseToolbarsManager.Tools.Exists("ChangeLogTool")) // Here we check to see if the tool exists yet - "ChangeLogTool" is the standard name Epicor gives it
    	{
        	_btlChgLog = new ButtonTool("ChangeLogTool"); // Create the new tool and put it in our variable
        	_btlChgLog.SharedProps.Caption = "Change Log...";
        	_btlChgLog.SharedProps.Category = "Actions";
        	DMRProcessingForm.setToolImage(_btlChgLog, "ChangeLog"); // This will add the book change log image to the button - you can find the list of names for icons by using the Epicor Resource Editor and opening the MfgBaseImages.resources file from the Client/res execution directory
        	baseToolbarsManager.Tools.Add(_btlChgLog); // This will add our new button to the toolbar
    	}
    	else
    	{
        	_btlChgLog = (ButtonTool)baseToolbarsManager.Tools["ChangeLogTool"];
    	}
         
    	_btlChgLog.SharedProps.Visible = true; // In all cases we want to ensure the button is visible
	}

	private void DMRProcessingForm_Load(object sender, EventArgs args)
	{
    	AddChgLogButton();
	}

	private void edvDMRHead_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
	{
		// ** Argument Properties and Uses **
		// view.dataView[args.Row]["FieldName"]
		// args.Row, args.Column, args.Sender, args.NotifyType
		// NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView, NotifyType.InitAndResetTreeNodes
		if ((args.NotifyType == EpiTransaction.NotifyType.Initialize))
		{
			if ((args.Row > -1))
			{
				_btlChgLog.SharedProps.Enabled = true;
			}
			else
			{
				_btlChgLog.SharedProps.Enabled = false;
			}
		}
	}

	private void baseToolbarsManager_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs args)
	{
		if (args.Tool.Key == "ChangeLogTool") // This method will fire for all tools clicked so we put this "if" here to capture the button we want and perform an action
    	{
        	if (edvDMRHead.Row > -1)
        	{
            	Epicor.Mfg.UI.App.ChgLogEntry.ChgLogArgs lfo  = new Epicor.Mfg.UI.App.ChgLogEntry.ChgLogArgs("DMRHead", edvDMRHead.dataView[edvDMRHead.Row]["RowIdent"].ToString(), true); // Let's evaluate this outside the code view... continue reading...
            	ProcessCaller.LaunchForm(oTrans, "Epicor.Mfg.UI.ChgLogEntry", lfo); // Launch the Change Log screen and behold the awesome
        	}
        	else
        	{
           	 args.Tool.SharedProps.Enabled = false; // If, for some (unlikely) reason, we get here in the tool click and there is no active record, just disable the button
        	}               
    	}
	}
}

Any suggestions would be helpful. I am just starting out with C#.

Michael

You need to call AddChgLogButton in InitializeCustomCode and remove from the form load event handler

Do I need to insert AddChgLogButton in DestroyCustomCode as well?

Actually, I put the AddChgLogButton in InitializeCustomCode and left it in the form load event handler and it worked.

So the modifcations worked in E9 without issue.

When I am converting to E10, I get the following errors:

image

What am I missing ?

Michael

Remove it from form load as it does no good a will cause unnecessary memory usage.

It’s located in the Ice.UI.App namespace

Ice.UI.App.ChgLogEntry

In Epicor 9, if I remove it from the form load, the change log button does not appear.

In Epicor 10, I changed all of the Erp.UI.App to Ice.UI.App and I get the following error when tring to compile:

image

Here is the latest code giving me the constructor error:

// **************************************************
// Custom code for DMRProcessingForm
// Created: 11/20/2018 6:00:41 PM
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Ice.Lib;
using Erp.BO;
using Ice.BO;
using Erp.Proxy.BO;
using Erp.UI;
using Ice.Adapters;
using Erp.Adapters;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.UI.FormFunctions;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Infragistics.Win.UltraWinToolbars;

public class Script
{
	// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
	// Begin Wizard Added Module Level Variables **

	// End Wizard Added Module Level Variables **

	// Add Custom Module Level Variables Here **
	private EpiDataView edvDMRHead;
	private ButtonTool _btlChgLog;

	public void InitializeCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
		// Begin Wizard Added Variable Initialization

		this.edvDMRHead = ((EpiDataView)(this.oTrans.EpiDataViews["DMRHead"]));
		this.edvDMRHead.EpiViewNotification += new EpiViewNotification(this.edvDMRHead_EpiViewNotification);
		this.baseToolbarsManager.ToolClick += new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(this.baseToolbarsManager_ToolClick);
		AddChgLogButton();
		// End Wizard Added Variable Initialization

		// Begin Wizard Added Custom Method Calls

		// End Wizard Added Custom Method Calls
	}

	public void DestroyCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
		// Begin Wizard Added Object Disposal

		this.edvDMRHead.EpiViewNotification -= new EpiViewNotification(this.edvDMRHead_EpiViewNotification);
		this.edvDMRHead = null;
		this.baseToolbarsManager.ToolClick -= new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(this.baseToolbarsManager_ToolClick);
		this._btlChgLog.Dispose();
		this._btlChgLog = null;
		// End Wizard Added Object Disposal

		// Begin Custom Code Disposal

		// End Custom Code Disposal
	}
	private void AddChgLogButton()
	{
    	if (!baseToolbarsManager.Tools.Exists("ChangeLogTool")) // Here we check to see if the tool exists yet - "ChangeLogTool" is the standard name Epicor gives it
    	{
        	_btlChgLog = new ButtonTool("ChangeLogTool"); // Create the new tool and put it in our variable
        	_btlChgLog.SharedProps.Caption = "Change Log...";
        	_btlChgLog.SharedProps.Category = "Actions";
        	DMRProcessingForm.setToolImage(_btlChgLog, "ChangeLog"); // This will add the book change log image to the button - you can find the list of names for icons by using the Epicor Resource Editor and opening the MfgBaseImages.resources file from the Client/res execution directory
        	baseToolbarsManager.Tools.Add(_btlChgLog); // This will add our new button to the toolbar
    	}
    	else
    	{
        	_btlChgLog = (ButtonTool)baseToolbarsManager.Tools["ChangeLogTool"];
    	}
         
    	_btlChgLog.SharedProps.Visible = true; // In all cases we want to ensure the button is visible
	}

	//private void DMRProcessingForm_Load(object sender, EventArgs args)
	//{
    //	AddChgLogButton();
	//}

	private void edvDMRHead_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
	{
		// ** Argument Properties and Uses **
		// view.dataView[args.Row]["FieldName"]
		// args.Row, args.Column, args.Sender, args.NotifyType
		// NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView, NotifyType.InitAndResetTreeNodes
		if ((args.NotifyType == EpiTransaction.NotifyType.Initialize))
		{
			if ((args.Row > -1))
			{
				_btlChgLog.SharedProps.Enabled = true;
			}
			else
			{
				_btlChgLog.SharedProps.Enabled = false;
			}
		}
	}

	private void baseToolbarsManager_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs args)
	{
		if (args.Tool.Key == "ChangeLogTool") // This method will fire for all tools clicked so we put this "if" here to capture the button we want and perform an action
    	{
        	if (edvDMRHead.Row > -1)
        	{
            	Ice.UI.App.ChgLogEntry.ChgLogArgs lfo  = new Ice.UI.App.ChgLogEntry.ChgLogArgs("DMRHead", edvDMRHead.dataView[edvDMRHead.Row]["RowIdent"].ToString(), true); // Let's evaluate this outside the code view... continue reading...
            	ProcessCaller.LaunchForm(oTrans, "Ice.UI.App.ChgLogEntry", lfo); // Launch the Change Log screen and behold the awesome
        	}
        	else
        	{
           	 args.Tool.SharedProps.Enabled = false; // If, for some (unlikely) reason, we get here in the tool click and there is no active record, just disable the button
        	}               
    	}
	}
}

ChgLogArgs now expects 4 arguments

public ChgLogArgs(string systemCode, string tableName, Guid rowIdent, bool showAsModal);
1 Like

Theodore -

Thank you for being patient with me. Like I said I am brand new to C#. If you could help out just a bit more it would be great.
Obviously, I am having a problem with the following line of code:

Ice.UI.App.ChgLogEntry.ChgLogArgs lfo  = new Ice.UI.App.ChgLogEntry.ChgLogArgs("DMRHead", edvDMRHead.dataView[edvDMRHead.Row]["RowIdent"].ToString(), true);

I know you said I need a fourth argument but I do not even know where to begin looking for what that should be.

Any help is greatly appreciated.

The four required arguments are in my last post, you are missing systemCode.

Change

Ice.UI.App.ChgLogEntry.ChgLogArgs lfo  = new Ice.UI.App.ChgLogEntry.ChgLogArgs("DMRHead", edvDMRHead.dataView[edvDMRHead.Row]["RowIdent"].ToString(), true);

to

Ice.UI.App.ChgLogEntry.ChgLogArgs lfo  = new Ice.UI.App.ChgLogEntry.ChgLogArgs("Erp", "DMRHead", edvDMRHead.dataView[edvDMRHead.Row]["RowIdent"].ToString(), true);

OK … changed that. Now I am getting the following compile error

Error: CS1502 - line 115 (311) - The best overloaded method match for ‘Ice.UI.App.ChgLogEntry.ChgLogArgs.ChgLogArgs(string, string, System.Guid, bool)’ has some invalid arguments
Error: CS1503 - line 115 (311) - Argument 3: cannot convert from ‘string’ to ‘System.Guid’

My bad forgot to change that, should be this.

Ice.UI.App.ChgLogEntry.ChgLogArgs lfo  = new Ice.UI.App.ChgLogEntry.ChgLogArgs("Erp", "DMRHead", Guid.Parse(edvDMRHead.dataView[edvDMRHead.Row]["RowIdent"].ToString()), true);

Almost there. That got it to compile. I have a change logs data directive setup and when I try to view it from the DMR Processing form, I get the following:

Theodore -

I got it. Changed “RowIdent” to “SysRowID” and it works.

Thank you for all of your help today.

Hi @MLW8595,
i am trying to implement your code in my test environment, did you add custom assembly reference to your form?

For Epicor 10 add a reference to

Ice.UI.ChgLogEntry

thanks for your reply mate, i have done that already and still asking for missing assembly reference
also tried without the [App], no luck

Try adding a reference to this one also.

Ice.Adapters.ChgLog
1 Like