Customization: Form Button Actions

Dumb question time.

We’re making some tweaks to the RMA form, our RMA’s are always tied to just one SO#, so our users want me to add a Sales Order search button to the Header tab. I’ve got my button created and the click event coded but not sure what code I need to active the standard SO search when the button is clicked and have the selected SO# populate a UD field.

I did something similar where I invoke a native search on the PerCon table.

private void btnOrigCnt_Click(object sender, System.EventArgs args)
	{
		//Launch PerCon Search
		bool recSelected = false;
		string whereClause = string.Empty;
		DataSet dsPerCon = Ice.UI.FormFunctions.SearchFunctions.listLookup(oTrans,"PerConAdapter", out recSelected, true, whereClause);
		if(recSelected)
		{
			var row = dsPerCon.Tables[0].Rows[0];
			
			//try binding to gridOrigDS
			//grdOrigDS.SetDataBinding(dsPerCon,"", false);
			//bind to edv
			////edvOrigView.dataView = dsPerCon.Tables["PerCon"].DefaultView;
			//txtOrigKey.Text = edvOrigView.dataView[edvOrigView.Row]["PerConID"].ToString();
		}
	}
1 Like

The customization wizard can walk you through this. It creates a chunk of code for you and all you have to do is either copy that code into the Click event, or call that code with something like:
SalesOrderAdapterSearch();

1 Like

Thanks @Aaron_Moreng and @Jason_Woods, with your clues I was able to get the Sales Order Search dialog to open, crashes after selecting a SO and clicking OK. I’m sure it’s that I don’t have it set to write back to the UD field correctly. The syntax is from the wizard except the Table_UDField named.

	private void btnSONum_Click(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here **
	
		// Wizard Generated Search Method
		// You will need to call this method from another method in custom code
		// For example, [Form]_Load or [Button]_Click

		bool recSelected;
		string whereClause = string.Empty;
		System.Data.DataSet dsSalesOrderAdapter = Ice.UI.FormFunctions.SearchFunctions.listLookup(this.oTrans, "SalesOrderAdapter", out recSelected, true, whereClause);
		if (recSelected)
		{
			System.Data.DataRow adapterRow = dsSalesOrderAdapter.Tables[0].Rows[0];

			// Map Search Fields to Application Fields
			EpiDataView edv = ((EpiDataView)(this.oTrans.EpiDataViews[""]));
			System.Data.DataRow edvRow = edv.CurrentDataRow;
			if ((edvRow != null))
			{
				edvRow.BeginEdit();
				edvRow["RMAHead_UDFieldName"] = adapterRow["OrderNum"];
				edvRow.EndEdit();
			}
		}
	}

image

EpiDataView edv = ((EpiDataView)(this.oTrans.EpiDataViews[""]));

Your epidataview is going after an empty, non-existant view. You’ll want to reference the RMAHead dataview i think

2 Likes

I owe you both a drink at Insights @Aaron_Moreng and @Jason_Woods

1 Like

Wish I could go!

I went last in 2017, didn’t get to last year. Since Vegas is much farther away than Nashville, I don’t about this year either.

I hope to attend some day. Haven’t been yet.

1 Like