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:
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#.
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
}
}
}
}
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.
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’
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: