jdtrent
(Joe D Trent)
July 22, 2022, 11:25pm
1
Hi,
I’m trying to trigger an update after a field change in UD102A, classic app customization.
It’s hitting the right spots in the code below and showing the data I expect at those spots, but the update doesn’t run. Clicking the save icon works.
Reckon what I missed?
Thanks,
Joe
private void UD102A_AfterFieldChange(object sender, DataColumnChangeEventArgs args)
{
// ** Argument Properties and Uses **
// args.Row["FieldName"]
// args.Column, args.ProposedValue, args.Row
// Add Event Handler Code
MessageBox.Show("arg " + args.Column.ColumnName);
switch (args.Column.ColumnName)
{
case "ASCINum_c":
MessageBox.Show(" actual field contents " + args.Row["ASCINum_c"].ToString());
//args.Row["RowMod"] = "U";
oTrans.Update();
MessageBox.Show(" arg " + args.Column.ColumnName);
break;
case "ASCommitHeat_c":
oTrans.Update();
MessageBox.Show(" arg " + args.Column.ColumnName);
break;
}
}
Try this.
just oTrans.Refresh() should do it. oh I’m sorry TLDR; LoL 2 secs.
Instead of PrintClientTool, call SaveTool (not sure). Do a debug to find out.
jdtrent
(Joe D Trent)
July 24, 2022, 3:16pm
3
Hi Louis,
I forgot about that bit 'o magic code. But it did about the same thing as the oTransUpdate. With it inside the AfterFieldChange method, the update did funky things. I guess the proposed value wasn’t set in the data row yet.
So I set a flag at that point and then ran the update in the notification as shown below. That seems to work okay.
Thanks for jogging my memory.
Joe
private void UD102A_AfterFieldChange(object sender, DataColumnChangeEventArgs args)
{
// ** Argument Properties and Uses **
// args.Row["FieldName"]
// args.Column, args.ProposedValue, args.Row
// Add Event Handler Code
switch (args.Column.ColumnName)
{
case "ASCINum_c":
saveSet = true;
break;
case "ASCommitHeat_c":
saveSet = true;
break;
}
}
private void edvUD102A_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
{
// ** Argument Properties and Uses **
// view.dataView[args.Row]["FieldName"]
// args.Row, args.Column, args.Sender, args.NotifyType
// NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView, NotifyType.InitAndResetTreeNodes
if ((args.NotifyType == EpiTransaction.NotifyType.Initialize))
{
if ((args.Row > -1))
{
if (saveSet)
{
saveSet = false;
oTrans.Update();
MessageBox.Show("in save");
}
}
saveSet = false;
}
}
Hi Joe,
I’m currently on vacation. Can’t do any test.
You probably know that a DataRow must have its RowState to Modified in order to be sent to the server for an update. I’m not sure how it’s works with UD child tables. I might have tried your args.Row[“RowMod”] = “U”; on the parent row instead. Just to see. But be careful when using that kind of assignement in an AfterFieldChange (DataColumnChanged) event. Preferably use boolean variable to control the flow of the code.
private void UD102A_AfterFieldChange(object sender, DataColumnChangeEventArgs args)
{
if(OnColumnChanged) return;
switch (args.Column.ColumnName)
{
case "ASCINum_c":
OnColumnChanged = true;
parentRow.Row["RowMod"] = "U";
OnColumnChanged = false;
break;
case "ASCommitHeat_c":
break;
}
}
I believe you get my point.
I would have tried an EndEdit() prior to your switch statement to see if it does something.
Anyway, Using Visual studio will allow you to watch the RowState and your proposed value easily.