Code for a Custom Refresh Button

I’m trying to make a custom refresh button, but the code will not compile.
What am I doing wrong? (I did have the Control type set as Epi Button when I tried.)

I have tried putting these under the “Place Event Code Here” separately:
oTrans.Refresh();
and
SendKeys.Send("{F5}"); (F5 is set up as a refresh hotkey)

What’s the error?

image

I mean it kinda tells you what the error is right there can you paste your entire code?

Sorry, this is my first time touching code in Epicor.
I’m pretty lost.

This is the Control Event Code, the only thing I am touching before it starts to give errors. :

private void epiButtonC1_Click(object sender, System.EventArgs args)
{
oTrans.Refresh();
}

You must be touching something else that error you are getting isn’t refering to this line, can you paste all your code (the entire script editor)

Also do you know/understand C#?

A little bit. I have only really ever used JavaScript (entirely different, I know), and it has been a long time.
And here:

// **************************************************
// Custom code for MainController
// Created: 12/4/2019 2:51:45 PM
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Ice.BO;
using Ice.UI;
using Ice.Lib;
using Ice.Adapters;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;

public class Script
{

	private Ice.Lib.Customization.CustomScriptManager csm;

	private Ice.UI.App.LynxUSA.MainController oTrans;

	private Ice.Lib.Framework.UIApp.EpiHostForm MainController;

	private Infragistics.Win.UltraWinToolbars.UltraToolbarsManager baseToolbarsManager;

	private System.Data.DataTable Results_Column;

	private Ice.Lib.Framework.BAQDataView V_LynxProgramData_1View_Row;

	private System.Data.DataTable BpmData_Column;

	private Ice.Lib.Framework.EpiDataView CallContextBpmData_Row;

	private System.Data.DataTable Client_Column;

	private Ice.Lib.Framework.EpiDataView CallContextClientData_Row;

	private Ice.Lib.Framework.EpiButton epiButtonC1;

	private Ice.Lib.Framework.EpiButton epiButtonC1_ff839913_47f4_4e41_bcc8_72ca2eddf3e7;

	public void InitializeGlobalVariables(Ice.Lib.Customization.CustomScriptManager csm)
	{
		this.csm = csm;
		this.oTrans = ((Ice.UI.App.LynxUSA.MainController)(this.csm.GetGlobalInstance("oTrans")));
		this.MainController = ((Ice.Lib.Framework.UIApp.EpiHostForm)(this.csm.GetGlobalInstance("MainController")));
		this.baseToolbarsManager = ((Infragistics.Win.UltraWinToolbars.UltraToolbarsManager)(this.csm.GetGlobalInstance("baseToolbarsManager")));
		this.Results_Column = ((System.Data.DataTable)(this.csm.GetGlobalInstance("Results_Column")));
		this.V_LynxProgramData_1View_Row = ((Ice.Lib.Framework.BAQDataView)(this.csm.GetGlobalInstance("V_LynxProgramData_1View_Row")));
		this.BpmData_Column = ((System.Data.DataTable)(this.csm.GetGlobalInstance("BpmData_Column")));
		this.CallContextBpmData_Row = ((Ice.Lib.Framework.EpiDataView)(this.csm.GetGlobalInstance("CallContextBpmData_Row")));
		this.Client_Column = ((System.Data.DataTable)(this.csm.GetGlobalInstance("Client_Column")));
		this.CallContextClientData_Row = ((Ice.Lib.Framework.EpiDataView)(this.csm.GetGlobalInstance("CallContextClientData_Row")));
		Ice.Lib.Customization.PersonalizeCustomizeManager personalizeCustomizeManager = this.csm.PersonalizeCustomizeManager;
		System.Windows.Forms.Control topControl = personalizeCustomizeManager.TopControl;
		topControl.FindForm().SuspendLayout();
		// Creating custom targets.
		this.epiButtonC1 = new Ice.Lib.Framework.EpiButton();
		this.epiButtonC1_ff839913_47f4_4e41_bcc8_72ca2eddf3e7 = this.epiButtonC1;
		System.Collections.Hashtable customControls = personalizeCustomizeManager.CustControlMan.CustomControlsHT;
		customControls.Add("ff839913-47f4-4e41-bcc8-72ca2eddf3e7", this.epiButtonC1);
		System.Collections.Hashtable controlsHT = personalizeCustomizeManager.ControlsHT;
		controlsHT.Add("ff839913-47f4-4e41-bcc8-72ca2eddf3e7", this.epiButtonC1);
		this.epiButtonC1.Name = "epiButtonC1";
		this.epiButtonC1.EpiGuid = "ff839913-47f4-4e41-bcc8-72ca2eddf3e7";
		// TrackerPanel
		Ice.Lib.Framework.EpiBasePanel local1 = ((Ice.Lib.Framework.EpiBasePanel)(personalizeCustomizeManager.ControlsHT["9fc6a346-e062-4c54-a790-6e37882f4463"]));
		local1.Controls.Add(this.epiButtonC1);
		local1.Controls.SetChildIndex(this.epiButtonC1, 0);
		System.Collections.Hashtable nativeSheets = personalizeCustomizeManager.NativeSheetsDCPsHT;
		Infragistics.Win.UltraWinDock.DockableControlPane local2 = Ice.Lib.Customization.Designers.EpiCustomSheetDesigner.GetDockableControlPane(local1, "9fc6a346-e062-4c54-a790-6e37882f4463", nativeSheets);
		// epiButtonC1
		this.epiButtonC1.Top = 6;
		this.epiButtonC1.Left = 282;
		this.epiButtonC1.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left);
		this.epiButtonC1.Width = 60;
		this.epiButtonC1.Height = 20;
		this.epiButtonC1.Text = "epiButtonC1";
		// MainController
		Ice.Lib.Framework.EpiBaseForm local3 = ((Ice.Lib.Framework.EpiBaseForm)(personalizeCustomizeManager.ControlsHT["B564E070-3328-4f86-BF70-DD1C139CCB21"]));
		local3.Top = -13;
		local3.Left = -1928;
		local3.Width = 1936;
		local3.Height = 1056;
		local3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F);
		// Finishing control initialization.
		topControl.FindForm().ResumeLayout();
	}

	public void DestroyGlobalVariables()
	{
		this.epiButtonC1 = null;
		this.epiButtonC1_ff839913_47f4_4e41_bcc8_72ca2eddf3e7 = null;
		this.csm = null;
		this.oTrans = null;
		this.MainController = null;
		this.baseToolbarsManager = null;
		this.Results_Column = null;
		this.V_LynxProgramData_1View_Row = null;
		this.BpmData_Column = null;
		this.CallContextBpmData_Row = null;
		this.Client_Column = null;
		this.CallContextClientData_Row = null;
	}

	public static string[] GetTranslatableStrings()
	{
		return new string[] {
				"epiButtonC1"};
	}

	public static string GetStringByID(string id)
	{
		return "";
	}
	// ** 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 **

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

		// End Wizard Added Variable Initialization

		// Begin Wizard Added Custom Method Calls

		this.epiButtonC1.Click += new System.EventHandler(this.epiButtonC1_Click);
		// 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.epiButtonC1.Click -= new System.EventHandler(this.epiButtonC1_Click);
		// End Wizard Added Object Disposal

		// Begin Custom Code Disposal

		// End Custom Code Disposal
	}

	private void epiButtonC1_Click(object sender, System.EventArgs args)
	{
		oTrans.Refresh();
	}");
	}");
	}
}

So you have a ton of extra } " ) at the end of your method not really sure how that happened… But that’s your issue. (if you look at your post I’ve formatted it for you, and you can clearly see the issue at the bottom there with the orange parenthesis and curly braces.

I recommend before proceeding much further that you do a thorought reading o the Epicor Ice Customization Guide, the Epicor Ice Tools Guide, and the Epicor Programmers Guide.
All available in EpicWeb

2 Likes

I’ve seen something like this lately if you don’t do the add of the event just right that you get some garbage at the bottom. When this happens I close the customization without saving and try adding it again.

Joe

2 Likes

When I needed to add a custom button to refresh my dashboard, I added this to the customization for the button code:

//Call Dash Refresh All
oTrans.PushStatusText("Refreshing all views. Please be patient...", false);      
MainController.AppControlPanel.HandleToolClick("RefreshAllTool", new 
Infragistics.Win.UltraWinToolbars.ToolClickEventArgs(MainController.MainToolManager.Tools["RefreshAllTool"], null)); 
oTrans.PushStatusText("Done!", false);

Also the documentation that Jose mentioned is a riveting couple of days worth of reading. :stuck_out_tongue_closed_eyes:
Good luck!

1 Like

Oh you might need to add some usings to the list at the top. TBH I am not sure which of these ones you actually need but this is what I had:

using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;
using System.Reflection;
1 Like

I actually got the refresh button working with the stuff I had in my original post.
Mostly had to get rid of the extra stuff that was being generated. Thanks, though!
I may come back to that in the future.

Have Any one tried to PustStatusText from BPM.

Please share it.

You can’t BPM runs server side. Status Text is client side…