E10 UD Adapter Add New Row


I have this code below, which is working fine. It looks up a record from UD14, updates it, and writes it back.

But I would like it to create a new row and add it to the table if it’s not already there.

I’ve tried something like:

	bool resultUD = adapterUD14.GetNewUD14;

in various forms, but I get the message there is no method associated with the adapter, or it can’t assign it.




extern alias Ice_Adapters_UD14;
extern alias Ice_Contracts_BO_UD14;

// write out to UD table
UD14Adapter adapterUD14 = new UD14Adapter(oTrans);

	bool resultUD = adapterUD14.GetByID("JobTraveler","PersonIDList","","","");

		//doesn't do anything - errors out with "record not found" if not in table

	DataRow drt = adapterUD14.UD14Data.UD14[0];
	drt["Character01"] = plannerOut;
	drt["RowMod"] = "U";

	MessageBox.Show("Error in UD14 Reference. Set up UD Record, Key1 = 'JobTraveler', Key2 = 'PersonIDList'");

Add the record manually and look at the trace, it should tell you what BO Method to use.

You need to call the method like this bool resultUD = adapterUD14.GetaNewUD14(); with the “a”.

Here’s an excerpt of what I use (minus my specific logic). I am using UD39Adapter. When you call GetNewUDxx, it places the new row into adapterName.UDxxData.Tables[0]. Note that I clear UDxxData each time before calling so I can ensure it is the only item there. You could do other logic to determine if it’s your new row, but I find this to be quick and painless

   public void baseCreateLabelRecord(string pn, decimal qty, bool master)
            string boxnum = "";
            string user = ((Session)oTrans.Session).UserID;


            if (a.GetaNewUD39())
                a.UD39Data.Tables[0].Rows[0][GetField("Job")] = CurrentJobNum;
                a.UD39Data.Tables[0].Rows[0][GetField("PartNum")] = pn;
                a.UD39Data.Tables[0].Rows[0][GetField("User")] = user;

                a.UD39Data.Tables[0].Rows[0]["Key5"] = "";
                a.UD39Data.Tables[0].Rows[0][GetField("Qty")] = qty;
                a.UD39Data.Tables[0].Rows[0]["Number05"] = 0; //reprints
                a.UD39Data.Tables[0].Rows[0]["Date01"] = DateTime.Now;
                a.UD39Data.Tables[0].Rows[0][GetField("VoidedBy")] = ""; //VoidedBy
                a.UD39Data.Tables[0].Rows[0][GetField("Voided")] = false; //voided
                a.UD39Data.Tables[0].Rows[0][GetField("Master")] = "";

            else MessageBox.Show("Failed to create record");


//I also use these helpers
 public string GetField(string field)
            string res = "";
            if (!FieldMap.TryGetValue(field, out res)) throw new Exception("Check your field map sucker!");
            return res;
        private void init_field_map()
            FieldMap.Add("Job", "Key1");
            FieldMap.Add("PartNum", "Key2");
            FieldMap.Add("User", "Key3");
            FieldMap.Add("BoxNum", "Key4");
            //FieldMap.Add("Job", "Key5");
            FieldMap.Add("Qty", "Number01");
            FieldMap.Add("Date", "Date01");
            FieldMap.Add("VoidedBy", "Character01");
            FieldMap.Add("Voided", "CheckBox01");
            FieldMap.Add("Processed", "CheckBox02");// has went thru prod door 
                                                    //do we  want a field to ref the actual partTran?

            FieldMap.Add("Master", "Character02");
            FieldMap.Add("Reprints", "Number05");
            FieldMap.Add("BoxCount", "Number06");