Can't set Selected Serial Numbers in BPM

,

I have been working on creating a BPM to automate some of the RMA process and am currently working with the creation of a new receipt process where a serial number must be selected. I have got the process working up until that last part where I get an error stating that I haven’t selected enough serial numbers. (Usually 0 of 1) I have performed a trace and compared the functions but don’t see anything obviously missing. I have also got this complete process working perfectly in a customization, but wanted to move it to a BPM.
The process is in an epicor function that is used in an update BPM on a UD table.

Any help towards solving this would be greatly appreciated!

Error:
ssnError

It would be best to see the code. Otherwise, we can’t tell you what is wrong.

I have done this before and the code to manipulate the selection lists was nothing short of gymnastics.

Here is the working code that I am trying to translate into a BPM

private void getNewReceipt()
	{
		EpiDataView edvCase = (EpiDataView)(oTrans.EpiDataViews["LateCase"]);

		RMAProcAdapter RMAAdapter  = new RMAProcAdapter(oTrans);
		RMAAdapter.BOConnect();

		SerialNoAdapter SNAdapter  = new SerialNoAdapter(oTrans);
		SNAdapter.BOConnect();

		bool userInput = false;
		int RMANum = (int)edvCase.dataView[edvCase.Row]["HDCase_RMANum"];
		int RMALine = (int)edvCase.dataView[edvCase.Row]["RMARcpt_RMALine"];
		string SerialNum = edvCase.dataView[edvCase.Row]["HDCase_SerialNumber"].ToString();
		string PartNum = edvCase.dataView[edvCase.Row]["HDCase_PartNum"].ToString();
		string empty = "";
		int test = 0;

		if(RMAAdapter.GetByID(RMANum))
		{
			SNAdapter.GetByID(PartNum, SerialNum);
			RMAAdapter.GetNewRMARcpt(RMANum, RMALine);
			RMAAdapter.RMAProcData.RMARcpt[0].ReceivedQty = 1; //decReceivedQty;
			RMAAdapter.RMAProcData.RMARcpt[0].WareHouseCode = "Service";

			RMAAdapter.ChangeWarehouse();

			RMAAdapter.RMAProcData.RMARcpt[0].BinNum = "Depot";
			RMAAdapter.RMAProcData.RMARcpt[0].RequestMove = false;
			RMAAdapter.RMAProcData.RMARcpt[0].SerialNumber = SerialNum;

			DataRow newRow = RMAAdapter.RMAProcData.SelectedSerialNumbers.NewSelectedSerialNumbersRow( );

			newRow[ "SerialNumber" ] = SerialNum;
			newRow[ "Company" ] = "EmbedTek";
			newRow[ "PartNum" ] = PartNum;
			newRow[ "NotSavedToDB" ] = true;
			RMAAdapter.RMAProcData.SelectedSerialNumbers.Rows.Add( newRow );
		}
		RMAAdapter.PreUpdate(out userInput);
		RMAAdapter.Update();
		RMAAdapter.Dispose();
		SNAdapter.Dispose();
	}

My solution required reflection. I cant outright share the code as it is a customer solution, but here is the method I used to commit my serial changes.

void CommitSerials(ConcurrentQueue<SelectedSerialNumbersDataSet> list, ProgressBar pb )
	{

		var sn = (SelectedSerialNumbersDataSet)oTrans.GetFieldValue("dsTempSelectedSN");
		foreach(var s in list)
		{		
			sn.SelectedSerialNumbers.Merge(s.SelectedSerialNumbers, true, MissingSchemaAction.Ignore);
			pb.PerformStep();
		}
		sn.AcceptChanges();                    
	}

I appreciate a look at the code but I needed this to work in an epicor function because of the issues with the RMA adapters not wanting to play nice. I was not able to get this done in a widget function so I moved everything to a custom code function and added it directly to the table. Works great now for automating the RMA Receipt creation and disposition process.

Hi - came across your post while also trying to automate RMA proc through a BPM. Seems like the Epicor RMA BO don’t like serial numbers. I keep running into the issue that I haven’t selected any serial numbers (when I have). You said you moved to custom code rather than the widgets, any chance you would share how you managed to do this?
Thanks
James

Sure, but forgive me as I retrace my steps on this project as I don’t recall everything I did.
To be specific I moved the code for creating the RMA receipt to an Epicor custom code function that I call in a BPM but it mostly follows what was listed above, minus some tweaks to get it to run in an Epicor function. The main addition that worked for me was making sure the RowMod of the SelectedSerialNumbers tableset was set to “A”. I believe this is what solved the error you are running into for me.