Updating JobHead row from UI Form Customization

We’re on 10.1.400.28. I’m attempting to set JobHead.JobReleased from a Customized UI Form ( UD08 Base ). The user sees a subset of data on an epiUltraGrid ( this works - the Job data is correct for the Serial Number entered ), then can click an epiButton to Release the Job.

In the current manual process, the user opens JobEntry to do this. In the Customization, I tried using the Methods for the JobEntry adapter. I started with ChangeJobHeadJobReleased - this is the code from the Business Logic Wizard :

private void CallJobEntryAdapterChangeJobHeadJobReleasedMethod()
{
try
{
// Declare and Initialize EpiDataView Variables
// Declare and create an instance of the Adapter.
JobEntryAdapter adapterJobEntry = new JobEntryAdapter(this.oTrans);
adapterJobEntry.BOConnect();

// Call Adapter method
bool result = adapterJobEntry.ChangeJobHeadJobReleased();

// Cleanup Adapter Reference
adapterJobEntry.Dispose();

} catch (System.Exception ex)
{
ExceptionBox.Show(ex);
}
}

No success. The two examples I found on the 'net for this method passed a dataset parameter to adapterJobEntry.ChangeJobHeadJobReleased(), but when I try this the compile fails - it won’t accept a parameter.

The compile succeeds without error if I omit the parameter, but clicking the button in the Customization results in the error :
Business Layer Exception
JobHead has not changed.
Exception caught in: Epicor.ServiceModel

Since adapterJobEntry.ChangeJobHeadJobReleased() won’t accept a parameter, I thought it may just affect the present data. On the JobEntry Adapter, I found CallJobEntryAdapterGetCurrentDataSetMethod() :

private void CallJobEntryAdapterGetCurrentDataSetMethod()
{
try
{
// Declare and Initialize EpiDataView Variables
// Declare and create an instance of the Adapter.
JobEntryAdapter adapterJobEntry = new JobEntryAdapter(this.oTrans);
adapterJobEntry.BOConnect();

// Declare and Initialize Variables
Ice.Lib.Searches.DataSetMode dsMode;

// Call Adapter method
System.Data.DataSet dsJobEntry = adapterJobEntry.GetCurrentDataSet(dsMode);

// Cleanup Adapter Reference
adapterJobEntry.Dispose();

} catch (System.Exception ex)
{
ExceptionBox.Show(ex);
}
}

Combining these, I put the JobReleased line into the GetCurrentDataSet after the call to GetCurrentDataSet, as shown below. This compiles, but results in a different error from the Customization :

private void CallJobEntryAdapterGetCurrentDataSetMethod()
{
try
{
// Declare and Initialize EpiDataView Variables
EpiDataView edv_WIP_Status = ((EpiDataView)(this.oTrans.EpiDataViews[“edv_WIP_Status”]));

// Check if valid EpiDataView Row(s) are selected
if ((edv_WIP_Status.Row < 0)) { return; }

// Declare and create an instance of the Adapter.
JobEntryAdapter adapterJobEntry = new JobEntryAdapter(this.oTrans);
adapterJobEntry.BOConnect();

// Declare and Initialize Variables
Ice.Lib.Searches.DataSetMode dsMode = ((Ice.Lib.Searches.DataSetMode)(edv_WIP_Status.dataView[edv_WIP_Status.Row][“JobHead_JobNum”]));

// Call Adapter method
System.Data.DataSet dsJobEntry = adapterJobEntry.GetCurrentDataSet(dsMode);

// Call Adapter method
bool result = adapterJobEntry.ChangeJobHeadJobReleased( );

// Cleanup Adapter Reference
adapterJobEntry.Dispose();

} catch (System.Exception ex)
{
ExceptionBox.Show(ex);
}
}

Clicking the button in the Customization with this code in place results in the error :
Application Error
Exception caught in: App.UD08Entry.UD08Form.EP.EmbedTek.Customization.ETK_Depot_Hydra_WIP.CustomCode
Error Detail

Message: Specified cast is not valid.
Program: App.UD08Entry.UD08Form.EP.EmbedTek.Customization.ETK_Depot_Hydra_WIP.CustomCode.dll
Method: CallJobEntryAdapterGetCurrentDataSetMethod
Client Stack Trace

at Script.CallJobEntryAdapterGetCurrentDataSetMethod()

Should I be trying to use ChangeJobHeadJobReleased to Release the Job ? I ran this by our resident EpiGuru. He made several attempts at getting the button-click to Release the Job by pulling the dataset differently and setting the Fields directly with an Update, but still no success. This is where the code is now :

private void CallJobEntryAdapterGetCurrentDataSetMethod()
{
try
{
// Declare and Initialize EpiDataView Variables
EpiDataView edv_WIP_Status = ((EpiDataView)(this.oTrans.EpiDataViews[“edv_WIP_Status”]));

// Check if valid EpiDataView Row(s) are selected
if ((edv_WIP_Status.Row < 0)) { return; }

// Declare and create an instance of the Adapter.
JobEntryAdapter adapterJobEntry = new JobEntryAdapter(this.oTrans);
adapterJobEntry.BOConnect();

// Declare and Initialize Variables
//Ice.Lib.Searches.DataSetMode dsMode = ((Ice.Lib.Searches.DataSetMode)(edv_WIP_Status.dataView[edv_WIP_Status.Row][“JobHead_JobNum”]));

//GetJobHead by ID
bool result = adapterJobEntry.GetByID(edv_WIP_Status.dataView[edv_WIP_Status.Row][“JobHead_JobNum”]);

//Create and JobHeadDataSet
//adapterJobEntry.GetByID(edv_WIP_Status.dataView[edv_WIP_Status.Row][“JobHead_JobNum”]);
//JobEntryDataSet jeData = adapterJobEntry.JobEntryData;
//JobHeadDataTable jhTable = adapterJobEntry.JobEntryData.JobHead;
JobEntryDataSet.JobHeadDataTable adapterRow = adapterJobEntry.JobEntryData.JobHead;
adapterJobEntry.Update ();
//JobEntryDataSet jobDS = adapterJobEntry.DataSet;
/*
sods = hSO.GetByID(OrderNr[i]);
sods.OrderHed[0][“c_ReprintEmail_c”]=true;
sods.OrderHed[0].RowMod=“U”;
hSO.Update (ref sods);

jobDS.[“JobReleased”] = true;
jobDS.[“JobEngineered”] = true;

*/
//Update JobEntry
// adapterJobEntry.Update(jobDS);

// Call Adapter method
//System.Data.DataSet dsJobEntry = adapterJobEntry.GetCurrentDataSet(dsMode);

// Call Adapter method
//bool result = adapterJobEntry.ChangeJobHeadJobReleased();

// Cleanup Adapter Reference
adapterJobEntry.Dispose();

} catch (System.Exception ex)
{
//ExceptionBox.Show(ex);
}
}

These approaches had similar results : either no change in the data, or the “JobHead has not changed” error I first had.

Thanks for reading,

Ken Brunelli, EmbedTek


	private void ProcessJobs()
	{
		int selectedCnt;
		string strCurrentRecord = string.Empty;
		string lotNum = string.Empty;
        JobEntryAdapter je = new JobEntryAdapter(oTrans);
        je.BOConnect();
		edvJob = oTrans.Factory("V_TesMaterialJobs_1View");
		edvJob.dataView.RowFilter = "JobHead_ProcessTest_c = true";
		DataTable dtf = edvJob.dataView.ToTable();
		selectedCnt = dtf.Rows.Count;
		edvJob.dataView.RowFilter = "";
        foreach (DataRowView dr in dtf.DefaultView)
        {
			string jobNum = dr["JobHead_JobNum"].ToString();
			string xrefPartNum = string.Empty;
			string xrefPartType = string.Empty;
			string vMsgText = string.Empty;
			string iPartNum = "99TEST";
			bool vSubAvail;
			string vMsgType = string.Empty;
			bool multipleMatch;
			string opMtlIssuedAction = string.Empty;
			bool opPartChgCompleted;
			je.ClearData();
			je.GetByID(jobNum);
			//MessageBox.Show("getbyID " + jobNum);
			je.JobEntryData.JobHead[0].JobEngineered = false;
			je.JobEntryData.JobHead[0]["ProcessTest_c"] = true;
			je.ChangeJobHeadJobEngineered();
			je.Update();
			var mtlRow = (JobEntryDataSet.JobMtlRow)je.JobEntryData.JobMtl.Select("MtlSeq = " + mtlSeq)[0];
			mtlRow.RowMod = "U";			
			je.ChangeJobMtlPartNum(true, ref iPartNum, Guid.Empty, xrefPartNum, xrefPartType, out vMsgText, out vSubAvail, out vMsgType, out multipleMatch, out opPartChgCompleted, out opMtlIssuedAction);
			mtlRow.Description = strPartDesc;
			je.Update();
			je.JobEntryData.JobHead[0].JobReleased = true;		
			je.ChangeJobHeadJobReleased();
			je.Update();

Ken, i hacked some of this snippet out of a dashboard i built to change materials on a job. It has to un-engineer and unrelease, make the changes then release. Note that precedence with engineered and released allows you to unrelease just by un-engineering, and releasing gets you engineered. You may not be dealing with that in your situations, i don’t know… I’m assuming of course you are starting or working with a FIRMED job in either event. I’m running this code in 10.1.500

2 Likes

Thanks, Rob. Our resident Guru pulled the relevant lines to plug into our code, and it works like a charm. We’re on 10.1.400.29 in Test, and there were no compatibility issues.
Thanks again,
Ken

hit me with a check box my friend :slight_smile:

Done !

1 Like