Add UD table as Child

I want to add a UD table as a child table. The wizard did pretty much all of the work, and I have a grid that I can add rows to. Now I want to change the menu words so it makes sense to the end user.

First I tried changing the words from the string “New UD11”. While it changed it in the menu, it also made the the new button not work (it wouldn’t add the new row). Is there another step that I need to take to make that work? I can’t see anywhere else where that string is used.

I think you can find the tool that it adds, which should be the same as the “AddText” and change the caption.

if (this.baseToolbarsManager.Tools.Exists("New UD11"))
{
     this.baseToolbarsManager.Tools["New UD11"].SharedProps.Caption= "New Caption Here";	 
}

I haven’t tested it so I’m not 100% the code will work for captions but I used similar code to hide the tool for certain users.

2 Likes

Yup that’s cause there is a Case Statement in the code (look for it) which uses the New UD11 as part of the Case.
So either change the caption (as @caleb.grundmeier mentioned) or change the name in both places. Where you point out and in the switch statement that calls GetNew()

I looked, and I still can’t find that case statement. If I search for “New UD11” it only shows up once in the whole script, which is where I show it.

Is this where it is? If it is, it’s throwing me off because it’s not the same string.

image

Edit: That was it. Seems goofy but it works.

2 Likes

The end is the same they append EpiAddNew at the beginning

quick question.

For the code below, it’s seems like it cares if the column is visible in the grid. It shouldn’t though right? When I try to add a new record, it’s telling me that it’s a duplicate row, which shouldn’t be possible with this loop in there. If I make the column visible however, it works fine. Is there a reason that this would be doing that?

	private void GetNewUD11Record()
	{
		DataRow parentViewRow = this._edvPREmployee.CurrentDataRow;
		// Check for existence of Parent Row.
		if ((parentViewRow == null))
		{
			return;
		}
		if (this._ud11Adapter.GetaNewUD11())
		{
			string empid = parentViewRow["EmpID"].ToString();

			// Get unique row count id for Key5
			int rowCount = this._ud11Adapter.UD11Data.UD11.Rows.Count;
			int lineNum = rowCount;
			bool goodIndex = false;
			while ((goodIndex == false))
			{
				// Check to see if index exists
				DataRow[] matchingRows = this._ud11Adapter.UD11Data.UD11.Select("Key5 = \'" + lineNum.ToString() + "\'");
				if ((matchingRows.Length > 0))
				{
					lineNum = (lineNum + 1);
				} else
				{
					goodIndex = true;
				}
			}
			}

			// Set initial UD Key values
			DataRow editRow = this._ud11Adapter.UD11Data.UD11.Rows[(rowCount - 1)];
			editRow.BeginEdit();
			editRow["Key1"] = empid;
			editRow["Key2"] = string.Empty;
			editRow["Key3"] = string.Empty;
			editRow["Key4"] = string.Empty;
			editRow["Key5"] = lineNum.ToString();
			editRow.EndEdit();

			// Notify that data was updated.
			this._edvUD11.Notify(new EpiNotifyArgs(this.oTrans, (rowCount - 1), this._edvUD11.Column));
		}

It should not care about column visible or not…
There should be more to this code. It sets Key5 to an autoincrement key. However a lot of times the GetUDXX function needs some tweaking. They (Epicor) assumes you are using all the other keys.
Looks like you are only using Key1 and Key5 , so modify the GetUDXX function to only care about Key1

Edit: My scroll was broken disregard the “more to this code”

I added the rest of it. It’s setting Key 5 to lineNum, which it figured out in that loop.

That was me…

1 Like

Then I take my edit back :smiley:

1 Like

So that “loop” won’t work unless your Get is working correctly. Is your “get” working correctly? As in are you getting back every record you insert?

yup, (you mean shows up when I load the parent record) that works fine.

It (everything) also works if I have the column visible.

That doesn’t make any sense… how are you making the column invisble?

just hiding/unhiding it in the grid that I bound to the view.

Weird… I kinda personally hate that stupid loop anyways. If you do’nt care about that value (in key5) I’d replace that whole loop with a simple Guid()

editRow["Key5"] = Guid.NewGuid().ToString();
2 Likes

Weird, I rehid it, now it’s working fine…

I am trying to add some BPM’s. I turned them off, but maybe they were still just screwing things up.

1 Like

So basically I just need this right?

		if (this._ud11Adapter.GetaNewUD11())
		{
			string empid = parentViewRow["EmpID"].ToString();
			
			// Get unique row count id for Key5
			int rowCount = this._ud11Adapter.UD11Data.UD11.Rows.Count;
			int lineNum = rowCount;
			
			// Set initial UD Key values
			DataRow editRow = this._ud11Adapter.UD11Data.UD11.Rows[(rowCount - 1)];
			editRow.BeginEdit();
			editRow["Key1"] = empid;
			editRow["Key2"] = string.Empty;
			editRow["Key3"] = string.Empty;
			editRow["Key4"] = string.Empty;
			editRow["Key5"] = Guid.NewGuid().ToString();
			editRow.EndEdit();

			// Notify that data was updated.
			this._edvUD11.Notify(new EpiNotifyArgs(this.oTrans, (rowCount - 1), this._edvUD11.Column));
		}
1 Like

Yup

1 Like

So I got all of that set up, new record works great. Even added today date in the that list to populate that when it’s created.

Next I want to create a new row when I add a new employee, with that date added. First I tried to add the case statement in the button block, but that doesn’t seem to work. I’m sure the add new employee get’s that button click first and doesn’t let it go.

	private void baseToolbarsManager_ToolClickForUD11(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs args)
	{
		// EpiMessageBox.Show(args.Tool.Key);
		switch (args.Tool.Key)
		{
			case "EpiAddNewNew Hire History":
				GetNewUD11Record();
				break;
			
			case "EpiAddNewNew Employee": //I added this, but it doesn't seem to work.
				GetNewUD11Record();
				break;
				
			case "ClearTool":
				ClearUD11Data();
				break;

			case "UndoTool":
				UndoUD11Changes();
				break;
		}
	}

I know that a BPM would work on save. Is that the best way to go about doing that? I was looking at the EpiViewNotifications, but I’m worried that would be anytime a row is added to the view, not necessarily the to the database, right? Or can I look at the row mod and if see if it’s an A?

Something like this from within the view notifaction

if(view.dataView[args.Row]["RowMod"].ToString() == "A")
{
GetNewUD11Record();
}

Edit: Well, that doesn’t work either, and it doesn’t work because there isn’t a userID assined yet, so the key is blank. So it is working, just not as how I intended it.

image

Guess the BPM route is the way to go.

Yeah BPM is probably your friend here.

ok, I know this is me being a little lazy, but how can I get the UD11 view to update after the BPM adds the row? Refresh doesn’t work, but clearing and re-loading the screen does, so the record is there.