Adding Change Log button to DMR Processing Toolbar

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

Ice.UI.App.ChgLogEntry
1 Like

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?

1 Like

For Epicor 10 add a reference to

Ice.UI.ChgLogEntry
1 Like

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
2 Likes

that is it, wonderful and many thanks, code compiled :heavy_check_mark::ok_hand::+1:
the button has not appeared yet, but i will work on that, appreciate your help mate

Thanks to all who help me work through this. For anyone else interested, below is the final code that compiled and worked for both DMR Processing and DMR Tracker.

// **************************************************
// 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("Erp","DMRHead", Guid.Parse(edvDMRHead.dataView[edvDMRHead.Row]["SysRowID"].ToString()), true); // Let's evaluate this outside the code view... continue reading...
            	ProcessCaller.LaunchForm(oTrans, "Ice.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
        	}               
    	}
	}
}
5 Likes

many thanks @MLW8595,
this is very generous of you, much appreciated :blue_heart:

Good Afternoon,

I got this working for the most part via Michael’s and Theodore’s code above (thank you!), but now I’m stuck. I want to view change log on the customer part cross reference program. I have a data directive setup and working on the CustXPrt table to log changes and it works. However, when the new change log toolbar icon is clicked in the customer part cross reference program, it doesn’t bring up the changed records. The one thing a little different with this change log on the CustXPrt is that it has a combination key getting stored in Key1 of the change log table, instead of just the sales order number (i.e., cust id ~ part no ~ cust part no ~ custxprt guid).
Could this be making a difference?

I don’t understand how this code works to bring up the right change log record(s) when it seems to be using the calling record guid to get it:

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

In the trace I have this that looks alot like the trace looks in sales order entry when I get the change log to come up with records. Any suggestions?


Sales order entry change log comes up ok, here’s similar trace:

Thanks!
Nancy

Thanks to everyone for posting this, I was able to get this to work.
A few notes:
-Version: 10.2.700 Classic UI
-I tried commenting out the OnLoad Event for Adding the ChgLogButton() and the button did not load. So I assume it has to be in both OnLoad and InitialzeCustomCode()
-The ‘Starburst’ does not show on the button when there is a change log, any idea how to add that functionality?
-Kinetic UI Fun Fact: The Change Log button already exists, not sure if it just looks for any Change Log records and if it exists, then adds the button or if change log exists for all forms.

Thanks again!

First of all thank you for providing this. I am at a total loss as to why Epicor did not think it important to include a change log for DMR Processing - one of the most important menu items for tracking quality changes. In any case your code worked for our 10.2.300.23 environment. Planning to migrate us to 10.2.700.23 this fall and hopefully the code will hold up unless Epicor has added a change log since.

My issue with this change log is that it does not have the ability to capture dates, numbers, or Char fields. I have added a bunch of UD fields all of which are selected in the Data Directive BPM yet when I review the change log none of these fields show up. I cannot figure out why. Things like drop down text boxes, check boxes, and ShortChar fields all get captured in the change log, but dates and Char fields do not. Any thoughts as to why?

Not a code expert, but if I had to venture a guess the issue lies here in the code:

Guid.Parse(edvDMRHead.dataView[edvDMRHead.Row][“SysRowID”].ToString()), true);

Perhaps the date fields cannot be converted to string? If that is the issue with date fields not showing up in the change log it still does not explain Char fields (Comments text boxes for example).

Any help would be greatly appreciated.

Thank you!