Change EpiShape status based on approved revision

I am trying to add a flag in Order Entry that will appear next to the Part/Rev under Lines | Detail that will let a user know if the revision is approved or not approved. I’ve been able to add a checkbox that links to the PartRev “Approved” field, but I would really like to have a EpiShape similar to the one in Method Tracker.

I tried adding a row rule, but that didn’t work. Is there a way to link an EpiShape to a field, similar to the mechanics of an EpiCheckBox? Also, if it isn’t possible to do that, could I link the EpiShape to my functioning checkbox (a last resort)?

You could put an AfterFieldChange event on the view.Field of your choice, then have that drive your EpiShape

I created a form event for AfterFieldChange for OrderDtl table, and RevisionNum field. From here, I’m not sure how to put the value of the PartRev “Approved” field into an if statement that controls the epiShape Status (epiShapeC1.Status = StatusTypes.OK or Warning).

Okay…making slow headway. The form event is working, because if I change value in revision dropdown it will display a message box. I am still stuck on how to check on the Approved field…

Is PartRev.Approved even a part of that form? If not it’s gonna require some more work:
Either FKV or custom code

I’ve used an FKV and Sub Table in Data Tools to pull in the PartRev table. I’ve been successful binding that to a checkbox. I guess my question is, how do I pull in a table field in as a variable in C#?

Ah nice, you’re ahead of the game then.

So in your onFieldChange (of the FKV), it would be similar to:

private void YourFKVl_AfterFieldChange(object sender, DataColumnChangeEventArgs args)
	{
		// ** Argument Properties and Uses **
		// args.Row["FieldName"]
		// args.Column, args.ProposedValue, args.Row
		// Add Event Handler Code
		switch (args.Column.ColumnName)
		{
			case "Approved":
                         if((bool)args.Row["Approved"] == true)
                        {
                             DoSomethingToYourShape
                         } 
                       else
                      {
                             DoSomethingElseToYourShape
                       }
				break;
		}
	}

When I try to set up a form event for PartRev, I get the following errors:

Error: CS1061 - line 47 (368) - 'Script' does not contain a definition for 'PartRev_Column' and no extension method 'PartRev_Column' accepting a first argument of type 'Script' could be found (are you missing a using directive or an assembly reference?)
Error: CS1061 - line 60 (381) - 'Script' does not contain a definition for 'PartRev_Column' and no extension method 'PartRev_Column' accepting a first argument of type 'Script' could be found (are you missing a using directive or an assembly reference?)

Is this because I have PartRev set up as a Sub Table to an FKV?

can u share code snippet?

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

		this.PartRev_Column.ColumnChanged += new DataColumnChangeEventHandler(this.PartRev_AfterFieldChange);
		// End Wizard Added Variable Initialization

		// Begin Wizard Added Custom Method Calls

		// 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.PartRev_Column.ColumnChanged -= new DataColumnChangeEventHandler(this.PartRev_AfterFieldChange);
		// End Wizard Added Object Disposal

		// Begin Custom Code Disposal

		// End Custom Code Disposal
	}

	private void PartRev_AfterFieldChange(object sender, DataColumnChangeEventArgs args)
	{
		// ** Argument Properties and Uses **
		// args.Row["FieldName"]
		// args.Column, args.ProposedValue, args.Row
		// Add Event Handler Code
		switch (args.Column.ColumnName)
		{
			case "Approved":
				MessageBox.Show("TEST");
				break;
		}
	}
}

Could this be part of the problem; how do I include PartRev here?

extern alias Erp_Contracts_BO_AlternatePart;
extern alias Erp_Contracts_BO_SalesOrder;
extern alias Erp_Contracts_BO_Quote;
extern alias Erp_Contracts_BO_Part;
extern alias Erp_Contracts_BO_Customer;
extern alias Erp_Contracts_BO_RMAProc;
extern alias Erp_Contracts_BO_OrderDtlSearch;
extern alias Erp_Contracts_BO_OrderHist;
extern alias Erp_Contracts_BO_QuoteDtlSearch;
extern alias Erp_Contracts_BO_SerialNumberSearch;
extern alias Erp_Contracts_BO_ShipTo;

Try to exchange PartRev.Column with myFKVTable and do:

EpiDataView myFKV;  //in custom variables
DataTable myFKVTable;

//in init
myFKV = oTrans.Factory("Name of your FKV");
myFKVTable = myFKV.dataView.Table;

//now you should be able to substitute as mentioned above

This threw a lot of errors…

Error: CS1061 - line 50 (371) - 'Script' does not contain a definition for 'myFKVTable_Column' and no extension method 'myFKVTable_Column' accepting a first argument of type 'Script' could be found (are you missing a using directive or an assembly reference?)
Error: CS1061 - line 50 (371) - 'Script' does not contain a definition for 'PartRev_AfterFieldChange' and no extension method 'PartRev_AfterFieldChange' accepting a first argument of type 'Script' could be found (are you missing a using directive or an assembly reference?)
Error: CS1061 - line 63 (384) - 'Script' does not contain a definition for 'myFKVTable_Column' and no extension method 'myFKVTable_Column' accepting a first argument of type 'Script' could be found (are you missing a using directive or an assembly reference?)
Error: CS1061 - line 63 (384) - 'Script' does not contain a definition for 'PartRev_AfterFieldChange' and no extension method 'PartRev_AfterFieldChange' accepting a first argument of type 'Script' could be found (are you missing a using directive or an assembly reference?)

Code:

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 **
	EpiDataView myFKV;
	DataTable myFKVTable;

	public void InitializeCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
		// Begin Wizard Added Variable Initialization
		myFKV = oTrans.Factory("Part");
		myFKVTable = myFKV.dataView.Table;
		this.myFKVTable_Column.ColumnChanged += new DataColumnChangeEventHandler(this.PartRev_AfterFieldChange);
		// End Wizard Added Variable Initialization

		// Begin Wizard Added Custom Method Calls

		// 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.myFKVTable_Column.ColumnChanged -= new DataColumnChangeEventHandler(this.PartRev_AfterFieldChange);
		// End Wizard Added Object Disposal

		// Begin Custom Code Disposal

		// End Custom Code Disposal
	}

	private void myFKVTable_AfterFieldChange(object sender, DataColumnChangeEventArgs args)
	{
		// ** Argument Properties and Uses **
		// args.Row["FieldName"]
		// args.Column, args.ProposedValue, args.Row
		// Add Event Handler Code
		switch (args.Column.ColumnName)
		{
			case "Approved":
				MessageBox.Show("TEST");
				break;
		}
	}
}

try:

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 **
	EpiDataView myFKV;
	DataTable myFKVTable;

	public void InitializeCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
		// Begin Wizard Added Variable Initialization
		myFKV = oTrans.Factory("Part");
		myFKVTable = myFKV.dataView.Table;
		this.myFKVTable.ColumnChanged += new DataColumnChangeEventHandler(this.myFKVTable_AfterFieldChange);
		// End Wizard Added Variable Initialization

		// Begin Wizard Added Custom Method Calls

		// 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.myFKVTable.ColumnChanged -= new DataColumnChangeEventHandler(this.myFKVTable_AfterFieldChange);
		// End Wizard Added Object Disposal

		// Begin Custom Code Disposal

		// End Custom Code Disposal
	}

	private void myFKVTable_AfterFieldChange(object sender, DataColumnChangeEventArgs args)
	{
		// ** Argument Properties and Uses **
		// args.Row["FieldName"]
		// args.Column, args.ProposedValue, args.Row
		// Add Event Handler Code
		switch (args.Column.ColumnName)
		{
			case "Approved":
				MessageBox.Show("TEST");
				break;
		}
	}
}

But isnt Part an existing system dataview?

To get to PartRev, I had to go to OrderDtl and create an FKV for Part, and then I created a STV on Part that linked to OrderDtl to get the revision number.

So you’ll want to use your STV name

I am still getting getting the “‘Script’ does not contain a definition for ‘mySTVTable_Column’…”

Thats because there is no mySTVTable_Column, its just mySTVTable

U know maybe I’ve taken you too far down the rabbit hole. How about you just place a change event on the row of the order detail (which would change the PN and ultimately drive the STV change) - inside of it, we’d just look up your value:

EpiDataView mySTV;
mySTV = oTrans.Factory("STV NAME");
bool myVal = (bool)mySTV.dataView[mySTV.Row]["Approved"];