UD05 Custom Form Blanks after oTrans.GetNew

I need some guidance to figure out why this custom form blanks after executing the UD05Form_Load code.

	{
		// Add Event Handler Code
	//**********************************
	// See if the UD05 record exist
	//**********************************
	

        string JobNum = "";
        string AsmSeq = "";
        string OprSeq = "";
        string OpCode = "";
        string Serial = ""; 

        //See if something is calling the form with parameters
        if (UD05Form.LaunchFormOptions != null)
        {
          if (UD05Form.LaunchFormOptions.ContextValue != null)
          {
              string MyData = UD05Form.LaunchFormOptions.ContextValue.ToString();
              if (MyData != "")
              {
                //Parse the "|" delimited string
                  string[] words = MyData.Split('|');
                  JobNum = words[0];
                  AsmSeq = words[1];
                  OpCode = words[2];
                  Serial = words[3];
                  OprSeq = words[4];
              }
          }
        }

        //Note:  If we are checking to see if the serial is not “” then we are eliminating FAB jobs from this process, may want to remove that check
        if (JobNum != "" && AsmSeq != "" && OprSeq != "" && Serial != "" && OpCode != "")
        {
          //Put the first code I sent you to Load to Create a UD05 record here
			bool RecordExist = false;
			string whereClause = "Company = 'DTSF' AND Key1 = '" + JobNum + "' AND Key2 = '" + AsmSeq + "' AND Key3 = '" + OpCode + "' AND Key4 = '" + Serial + "' AND Key5 = '" + OprSeq + "'";
			bool recordSelected;
			bool showSearch = false;
			DataSet fSet = SearchFunctions.listLookup(UD05Form, "UD05Adapter", out recordSelected, showSearch, whereClause);
		
			//If record exist…
			if (fSet.Tables[0].Rows.Count > 0)
			{
			  oTrans.GetByID(JobNum, AsmSeq, OpCode, Serial, OprSeq);
			} 
			 //Else, record does not exist
			else
			{
			    //Record Does Not Exist.  
			    oTrans.GetNew(JobNum, AsmSeq, OpCode, Serial, OprSeq);
                oTrans.Update();
			
			    oTrans.GetByID(JobNum, AsmSeq, OpCode, Serial, OprSeq);
 
                EpiDataView edv = (EpiDataView)(oTrans.EpiDataViews["UD05"]);
                //edv.dataView[edv.Row]["Key1"] = JobNum;
                //edv.dataView[edv.Row]["Key2"] = AsmSeq;
                //edv.dataView[edv.Row]["Key3"] = OpCode;
                //edv.dataView[edv.Row]["Key4"] = Serial;
                //edv.dataView[edv.Row]["Key5"] = OprSeq;
				
				string baqID = "DTSF-JobAssemDesc";
				DynamicQueryAdapter dyAdpt = new DynamicQueryAdapter(UD05Form);
		        dyAdpt.BOConnect();
				Ice.BO.QueryExecutionDataSet execSet = dyAdpt.GetQueryExecutionParametersByID(baqID);
		        execSet.ExecutionParameter.Clear();
				execSet.ExecutionParameter.AddExecutionParameterRow("JobNum", JobNum, "nvarchar", false, Guid.NewGuid(), "A");
				execSet.ExecutionParameter.AddExecutionParameterRow("AsmSeq", AsmSeq, "int", false, Guid.NewGuid(), "A");
		        dyAdpt.ExecuteByID(baqID, execSet);
		        edv.dataView[edv.Row]["Character01"] = dyAdpt.QueryResults.Tables["Results"].Rows[0]["JobAsmbl_Description"].ToString();
				//edv.dataView[edv.Row]["ShortChar03"] = dyAdpt.QueryResults.Tables["Results"].Rows[0]["JobAsmbl_ShortChar01"].ToString();
				//edv.dataView[edv.Row]["ShortChar10"] = dyAdpt.QueryResults.Tables["Results"].Rows[0]["JobAsmbl_ShortChar08"].ToString();
				//edv.dataView[edv.Row]["ShortChar11"] = dyAdpt.QueryResults.Tables["Results"].Rows[0]["JobAsmbl_ShortChar09"].ToString();
				neTempPrintLength.Value = Convert.ToDouble(dyAdpt.QueryResults.Tables["Results"].Rows[0]["JobAsmbl_Number01"].ToString());
				nePrintTopStrap.Value = Convert.ToDouble(dyAdpt.QueryResults.Tables["Results"].Rows[0]["JobAsmbl_Number08"].ToString());
				nePrintBotStrap.Value = Convert.ToDouble(dyAdpt.QueryResults.Tables["Results"].Rows[0]["JobAsmbl_Number09"].ToString());
				edv.dataView[edv.Row]["ShortChar03"] = GetFractionalForm(Convert.ToDouble(neTempPrintLength.Value.ToString()));
				edv.dataView[edv.Row]["ShortChar10"] = GetFractionalForm(Convert.ToDouble(nePrintTopStrap.Value.ToString()));
				edv.dataView[edv.Row]["ShortChar11"] = GetFractionalForm(Convert.ToDouble(nePrintBotStrap.Value.ToString()));
				dyAdpt.Dispose();
		        //txtDesc.ReadOnly = true; 

                //oTrans.JobNum, AsmSeq, OpCode, Serial, OprSeq);
			}
        }


	}```

Form_Load usually executes before the local dataset is retrieved. You probably want to use an event related to when after the dataset is retrieved.

This code only does something if the form is called with LaunchFormOptions defined. Are you calling this from other custom code?
Did you verify the LFO has the expected values(job, asm seq, op seq, serial and op code)?

Yes these values load correctly.

Thanks

@ckrusen Any chance you could throw me an example of what you are referring to?

Thanks!

I removed the LFO and BAQ lookup logic and hard coded some key values and this generally works as expected:

  1. Initial Form Open: New UD05 row is created w/o issue
  2. Close and Reopen Form: Existing UD05 row is loaded w/o issue

Are you handling any other events?

The only other thing i did was to set the combo boxes Property RetrieveOnActivate to False and loaded EpiStaticDataList
with this on some and

Results
Pass
Reject

this on others

Results
N/A
Pass
Reject

What happens if you comment out the entire section involving the DynamicQueryAdapter?
Can you attach Visual Studio?

Do you mean am i using Visual Studio to debug? Yes
Tested Commenting out the DynamicQueryAdapter and hard coded the values that load to
neTempPrintLength.Value = 1111.11;
nePrintTopStrap.Value = 8888.88;
nePrintBotStrap.Value = 9999.99;

Same result Form blanks after briefly displaying values.

Do you want to see all the code from Visual Studio?

Do you have any method or data directives on UD05?

Nope it is a “virgin” table used for just for this application.

Just an update for a work around that we tried. We put a button on the form to perform the event that we attempted in the Form_Load and were successful at creating a new record and retrieving an exisiting record from UD05.

This does create another “click” that will need to happen. Does anyone know of an “after” form_load method we can use? We can’t seem to find one.

If not, thanks for your help we are moving in the right direction.

Did you ever figure this out? I am trying to set a default when a New PO is entered.

No we left it with using a button click for the event to populate the form. Sorry.