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.
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()
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”
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
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.
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.