# E10 UD Adapter Add New Row

**URL:** <https://www.epiusers.help/t/e10-ud-adapter-add-new-row/39908>\
**Category:** Epicor ERP 10\
**Created:** [August 17, 2017, 7:25pm UTC](https://www.epiusers.help/t/e10-ud-adapter-add-new-row/39908 "2017-08-17T19:25:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdtrent](https://www.epiusers.help/user_avatar/www.epiusers.help/jdtrent/32/915_2.png) [@jdtrent](https://www.epiusers.help/u/jdtrent)\
**Post date:** [August 17, 2017, 7:25pm UTC](https://www.epiusers.help/t/e10-ud-adapter-add-new-row/39908/1 "2017-08-17T19:25:42Z")

</div>

Hi,

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.

Hint?

Thanks,

Joe

* * *

extern alias Ice\_Adapters\_UD14;  
extern alias Ice\_Contracts\_BO\_UD14;

…

try  
{  
// write out to UD table  
UD14Adapter adapterUD14 = new UD14Adapter(oTrans);  
adapterUD14.BOConnect();

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

	if(resultUD)
	{
		//doesn't do anything - errors out with "record not found" if not in table
	}

	DataRow drt = adapterUD14.UD14Data.UD14[0];
	
	drt.BeginEdit();
	drt["Character01"] = plannerOut;
	//MessageBox.Show(adapterUD14.UD14Data.UD14[0]["Character01"].ToString());
	drt["RowMod"] = "U";
	drt.EndEdit();

	adapterUD14.Update();
	adapterUD14.Dispose();
}
catch
{
	MessageBox.Show("Error in UD14 Reference. Set up UD Record, Key1 = 'JobTraveler', Key2 = 'PersonIDList'");
}
```

---

<div class="post-metadata">

**Author:** ![josecgomez](https://www.epiusers.help/user_avatar/www.epiusers.help/josecgomez/32/55731_2.png) [@josecgomez](https://www.epiusers.help/u/josecgomez)\
**Post date:** [August 17, 2017, 8:21pm UTC](https://www.epiusers.help/t/e10-ud-adapter-add-new-row/39908/2 "2017-08-17T20:21:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Didier\_Vanegas](https://www.epiusers.help/user_avatar/www.epiusers.help/didier_vanegas/32/919_2.png) [@Didier\_Vanegas](https://www.epiusers.help/u/Didier_Vanegas)\
**Post date:** [August 18, 2017, 4:04am UTC](https://www.epiusers.help/t/e10-ud-adapter-add-new-row/39908/3 "2017-08-18T04:04:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Chris\_Conn](https://www.epiusers.help/user_avatar/www.epiusers.help/chris_conn/32/93797_2.png) [@Chris\_Conn](https://www.epiusers.help/u/Chris_Conn)\
**Post date:** [August 18, 2017, 1:19pm UTC](https://www.epiusers.help/t/e10-ud-adapter-add-new-row/39908/4 "2017-08-18T13:19:07Z")

</div>

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

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

           a.ClearData();

            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")] = "";

                a.Update();
            }
            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.Clear();
            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");
        }

```
