Must set Static Filter before setting Parent/Child relations

Usually when you try to add a child to a Node that uses the JobLib Tree (OprSeq, MtlSeq…) Epicor behind the scenes uses a special library they created Erp.UI.FrameWork.JobLib.

So instead of using the traditional InitializeUDXXAdapter() method boiler plate code, you should add your child to the ViewManager.

Example:

	private void InitializeUD09Adapter()
	{
		// Create an instance of the Adapter.
		this._ud09Adapter = new UD09Adapter(this.oTrans);
		this._ud09Adapter.BOConnect();

		// Add Adapter Table to List of Views
		// This allows you to bind controls to the custom UD Table
		this._edvUD09 = new EpiDataView();
		this._edvUD09.dataView = new DataView(this._ud09Adapter.UD09Data.UD09);
		this._edvUD09.AddEnabled = true;
		this._edvUD09.AddText = "New UD09";
		if ((this.oTrans.EpiDataViews.ContainsKey("UD09View") == false))
		{
			this.oTrans.Add("UD09View", this._edvUD09);
		}

		// Initialize DataTable variable
		this.UD09_Column = this._ud09Adapter.UD09Data.UD09;

		this._edvJobMtl = ((EpiDataView)(this.oTrans.EpiDataViews["JobMtl"]));
		Erp.UI.FrameWork.JobLib.EpiDataViewRelation jobMtlUD09Relation = new Erp.UI.FrameWork.JobLib.EpiDataViewRelation(this._edvUD09);
		Erp.UI.FrameWork.JobLib.EpiDataViewRelation mtlRelation = new Erp.UI.FrameWork.JobLib.EpiDataViewRelation(this._edvJobMtl);

		// Set the parent view / keys for UD child view
		string[] parentKeyFields = new string[] { "JobNum", "AssemblySeq", "MtlSeq" };
		string[] childKeyFields = new string[] { "Key1", "Key2", "Key3" };

		// Use SetParent not SetParentView
		jobMtlUD09Relation.SetParent(mtlRelation, parentKeyFields, childKeyFields);

		// Magic Here
		Erp.UI.FrameWork.JobLib.EpiDataViewFilterManager x = new Erp.UI.FrameWork.JobLib.EpiDataViewFilterManager(this.oTrans);
		x.AddRelation(jobMtlUD09Relation);
	}

The other option you have is adding your own clone of lets say JobMtl and call it JobCustomMtl and then adding your UD as a child to JobCustomMtl.

3 Likes