Hi,
I have had a lot of help from this forum before but I am reaching out again as I can’t figure out what is going on with my code.
I have put a Dynamic method call in my customisation which I want to fire from a button click however it runs when I open the dashboard. I have done this a few times before and I can’t see the difference in the script, any help would be greatly appreciated.
// **************************************************
// Custom code for MainController
// Created: 27/01/2021 16:27:56
// **************************************************
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;
using Ice.Bpm.Context;
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 **
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)
{
// ** Place Event Handling Code Here **
CallDynamicQueryAdapterGetBaqDataViewQueryMethod();
}
private void CallDynamicQueryAdapterGetBaqDataViewQueryMethod()
{
try
{
// Declare and Initialize EpiDataView Variables
EpiDataView edvV_Attachements_1View = ((EpiDataView)(this.oTrans.EpiDataViews["V_Attachements_1View"]));
// Check if valid EpiDataView Row(s) are selected
if ((edvV_Attachements_1View.Row < 0))
{
return;
}
// Declare and create an instance of the Adapter.
DynamicQueryAdapter adapterDynamicQuery = new DynamicQueryAdapter(this.oTrans);
adapterDynamicQuery.BOConnect();
// Declare and Initialize Variables
// TODO: You may need to replace the default initialization with valid values as required for the BL method call.
string pcQueryId = ((string)(edvV_Attachements_1View.dataView[edvV_Attachements_1View.Row]["Attachements"]));
{
adapterDynamicQuery.BpmContext = new ContextDataSet();
var row = adapterDynamicQuery.BpmContext.BpmData.NewRow();
row["Number01"] = ((edvV_Attachements_1View.dataView[edvV_Attachements_1View.Row]["XFileRef_XFileRefNum"]));
row["SysRowID"] = Guid.Empty;
adapterDynamicQuery.BpmContext.BpmData.Rows.Add(row);
}
// Call Adapter method
bool result = adapterDynamicQuery.GetBaqDataViewQuery(pcQueryId);
// Cleanup Adapter Reference
adapterDynamicQuery.Dispose();
} catch (System.Exception ex)
{
ExceptionBox.Show(ex);
}
}
}
Allan