Forcing a save from EpiViewNotification in Case Entry

So in Case Entry when I save a new case (in certain instances) I need the first task to be automagically marked completed and the second task brought in. This has not been as easy as it sounds.

Since the task BO isn’t run from the case BO, the only access I have to the task on a BPM is via a data directive. It all works fine, except the client side data doesn’t match and we get the “other user modified the row” message when saving.

So I’ve ended up in the customization checking the task edv from the notification. And that works okay, except if I include oTransUpdate I get the first TWO tasks completed and the third added, so I took the update out. (Having a save in the notification seems like a bad idea anyway.)

If the user hits save again at this point we’re good, but they might well not.

Even though I’ve changed the data, I don’t get a save prompt if I clear, exit, or open a new case. I’ve set the rowmod to “U” for both the task row and the case row (edvHDCase). I would think setting the rowmods would trigger the “do you want to clear” message ??

If the user leaves the record, we lose the completion of the task, even though it’s checked.

Care to see what I’ve done wrong?

Thanks,

Joe

	private void edvTask_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 (edvTask.dataView[args.Row]["TaskSetID"].ToString() == "ES-NoRMA" && edvTask.dataView[args.Row]["TaskSeqNum"].ToString() == "10" && 
				edvTask.dataView[args.Row]["RelatedToFile"].ToString() == "HDCase" && Convert.ToBoolean(edvTask.dataView[args.Row]["Complete"]) == false)
				{
					edvTask.dataView[args.Row].BeginEdit();
					edvTask.dataView[args.Row]["Complete"] = true;
					edvTask.dataView[args.Row]["RowMod"] = "U";
					edvTask.dataView[args.Row].EndEdit();

					edvHDCase.dataView[args.Row].BeginEdit();
					edvHDCase.CurrentDataRow["RowMod"] = "U";
					edvHDCase.dataView[args.Row].EndEdit();
					//oTrans.Update();
				}
			}
		}
	}

Amended to correct a copy/paste error, but same result.

					edvHDCase.CurrentDataRow.BeginEdit();
					edvHDCase.CurrentDataRow["RowMod"] = "U";
					edvHDCase.CurrentDataRow.EndEdit();

I haven’t specifically worked with the Case or Task BOs before, but I’ve had a similar situation with the Customer and CustCnt BOs - where a user action on one BO needs to do something to the other BO, and then the client screen needs to “refresh” to prevent the “row has been modified” error…

Here’s what I’d try, based on what worked for me in the past:

  1. Start with a method directive BPM on the Case BO… make sure it only fires once in the right conditions
  2. In that BPM add a reference for the Task assembly/BO so you can call all the methods and such
  3. Run a trace for the process of completing one task and bringing in a second, and then mimic the trace method calls with your BPM code
  4. At the very end of that BPM, create a “flag” by setting one of the callContextBpmData fields to some arbitrary value (this is how we can trigger the screen refresh later)
  5. Then, in a Case Entry customization, add an “AfterAdapterMethod” event handler method where you look for that callContextBpmData flag you set in the BPM
  6. When the flag is “true”, add an oTrans.Refresh() and then set the flag to “false” so you don’t fall into an endless loop of screen refreshing…

I’m sure there probably is a way to get it all working with just a customization, but it could get really tricky. EpiViewNotifications are notoriously difficult to use as event handlers because they tend to fire a million times with little rhyme or reason… Not to mention, none of that code will work in Kinetic so it’s better to do the heavier lifting in a BPM if you can.

1 Like

Thanks, Tom.

I needed it to work “right now,” so I did it in the customization. I had a custom grid already attached to Task, with on row activation code for another purpose. I added a section there to check the first row in the dataview and set the complete flag, then do an update if it fit the criteria. Works fine. Maybe someone else will have to figure out how to do it in Kinetic. This Case customization was already heavily customized anyway.

I will tuck this info away, though. :slight_smile:

Joe

1 Like