Customization UD Child Records not Refreshing

I was having an issue in my Sales Order Entry customization, which I had modified to include Child UD Table records. The data is being populated outside the customization in a BPM, trigged by a OrderHed UDF value and oTrans.Update.

However, after the child records were created the did not show in Sales Order Entry until after I cleared and refreshed the form, or moved to another order.

After reading some old post I had an idea of how to correct the issue.

I created a boolean variable, bForceRefresh, that I set when I want the UD table records to refresh. Then set it to true and call the GetUDxx method, which was created with the Customization Wizard’s Child UD Table functionality.

I then modified the GetUDxx method, which is verifying that the keys have changed, to include an OR statement which looks at the bForceRefresh. If it is set, it performs the refresh anyway, which is what want.

I am going to reply to my message with some code segments.

//
// original GetUD02Data method with bForceRefresh check and clear.
// Only lines with the bForceRefresh are modified
//
bool bForceRefresh = false;
	private void GetUD02Data(string key1, string key2, string key3, string key4, string key5)
	{
		i**f (((this._Key1UD02 != key1) || (this._Key2UD02 != key2) || (this._Key3UD02 != key3) || (this._Key4UD02 != key4) || (this._Key5UD02 != key5)) || (bForceRefresh))**
		{
			// Build where clause for search.
			string whereClause = "Key1 = \'" + key1 + "\' And Key2 = \'" + key2 + "\' And Key3 = \'" + key3 + "\' And Key4 = \'" + key4 + "\'";
			System.Collections.Hashtable whereClauses = new System.Collections.Hashtable(1);
			whereClauses.Add("UD02", whereClause);

			// Call the adapter search.
			SearchOptions searchOptions = SearchOptions.CreateRuntimeSearch(whereClauses, DataSetMode.RowsDataSet);
			this._ud02Adapter.InvokeSearch(searchOptions);

			if ((this._ud02Adapter.UD02Data.UD02.Rows.Count > 0))
			{
				this._edvUD02.Row = 0;
			} else
			{
				this._edvUD02.Row = -1;
			}

			// Notify that data was updated.
			this._edvUD02.Notify(new EpiNotifyArgs(this.oTrans, this._edvUD02.Row, this._edvUD02.Column));

			// Set key fields to their new values.
			this._Key1UD02 = key1;
			this._Key2UD02 = key2;
			this._Key3UD02 = key3;
			this._Key4UD02 = key4;
			this._Key5UD02 = key5;

			bForceRefresh = false;
		}
	}
	//
	// Method to trigger the save and refresh
	//
	private void btnBundleRegeneration_Click(object sender, System.EventArgs args)
	{
		chkRegenBundles.Checked = true; // Set UDF to trigger the SalesOrder.MasterUpdate BPM
		oTrans.Update();
		
		oTrans.Refresh();
		
		bForceRefresh = true;
		GetUD02Data(oTrans.KeyField, "", "", "", "");
	}
1 Like

I’m not positive about this, but I personally, would want the oTrans.Refresh(); to happen AFTER the GetUD02Data call rather than before it. Just seems to me to make more sense to refresh the screen after the data change. But I definitely could be wrong :slight_smile:

The oTrans.Refresh() refreshes all the standard objects, but doesn’t refresh the custom/child UD02.

Therefore, since the UD02 is a child of the standard objects, it made sense to me to update it afterwards.