Edit Table from an Unrelated Form

I’m looking for the best way to edit a row in the JobMtl Table from a customization in the Purchase Order Entry Form.
I think the JobEntryAdapter is the way to go…but have never used an adapter and don’t really know what to do with it.
I used GetByIdandJobType to get the job I want to work on.
Just not sure what to do next… Any Tips?

I also just found a pretty useful looking function in the job entry adapter that I think should give me the row in JobMtl I need, but not sure what to do with it once I have it, how do you use a dataset row like this one?

Erp.BO.JobEntryDataSet.JobMtlRow jobMtlDsR = MyJobEntryAdapter.JobEntryData.JobMtl.FindByCompanyJobNumAssemblySeqMtlSeq(Company, jobNum, AsSeq, MtlSeq);

First, I’d definitely be careful. When we get under the hood, the limitations seem to disappear.

In general, I’d say:
jobMtlDsR.BeginEdit();
jobMtlDsR.SomeField = “Some Value”;
jobMtlDsR.EndEdit();

Thanks Chris, that was a big help, I feel like I’m super close on this, I’m able to get all of the values out of the row if I need to use them now, and I can set the fields in the row to new values, but the change isn’t showing up in the JobMtl table after I change the row. How do I update the table once the row has been changed? I show my code below. Thanks.

                         //initialize the job entry adapter
				Erp.Adapters.JobEntryAdapter MyJobEntryAdapter  = new Erp.Adapters.JobEntryAdapter(POSuggEntryForm);
				MyJobEntryAdapter.BOConnect();
				//Get the job
				Boolean success = MyJobEntryAdapter.GetByIdandJobType(jobNum, jobType);
				//Get the JobMtl Row
				Erp.BO.JobEntryDataSet.JobMtlRow jobMtlDsR = MyJobEntryAdapter.JobEntryData.JobMtl.FindByCompanyJobNumAssemblySeqMtlSeq(Company, jobNum, AsSeq, MtlSeq);
				//Edit the row
				jobMtlDsR.BeginEdit();
				jobMtlDsR.RevisionNum = "A";	
				jobMtlDsR.EndEdit();	
			
				//****Here Need a way to update the JobMtl Table to reflect changes to the Row ***
				 	
				//Dispose of the adapater
				MyJobEntryAdapter.Dispose();

Before EndEdit() you’ll probably need to set jobMtlDsR.RowMod = “U”; //says the row has been updated

Right where you say you need to update put:
MyJobEntryAdapter.Update();

Wait - I just noticed you are working with a dataset here. You’re going to have to import that row back into the adapters data.
Maybe use: MyJobEntryAdapter.JobEntryData.JobMtl.ImportRow(jobMtlDsR);

Something like this will work. It does use POEntryForm instead of POSuggEntryForm but you can just change

				JobEntryAdapter MyJobEntryAdapter  = new JobEntryAdapter(POEntryForm);
				MyJobEntryAdapter.BOConnect();
				//Get the job
				Boolean success = MyJobEntryAdapter.GetByIdandJobType(jobNum, jobType);
				//Get the JobMtl Row
				Erp.BO.JobEntryDataSet.JobMtlRow jobMtlDsR = MyJobEntryAdapter.JobEntryData.JobMtl.FindByCompanyJobNumAssemblySeqMtlSeq(Company,jobNum,AsSeq,MtlSeq);
				jobMtlDsR.RevisionNum = "A";	
				jobMtlDsR.RowMod = "U";
				MyJobEntryAdapter.Update();	 	
				//Dispose of the adapater
				MyJobEntryAdapter.Dispose();

Thanks guys,
I got this working!
I didn’t have to import the row. This is what I ended up with:

jobMtlDsR.BeginEdit();
jobMtlDsR.RevisionNum = “A”;
jobMtlDsR.RowMod = “U”;
jobMtlDsR.EndEdit();
MyJobEntryAdapter.Update();

1 Like

Great. You could remove the BeginEdit and EndEdit if you wanted to keep the code clean. I believe setting the RowMod handles this for you, in this example.

In that case I learn something new today as well @danbedwards.