Another EpiShape Question - Change Color based on field value

Struggling to get the results I want.
I created a few UD fields in JobHead table that are boolean. They are represented by a check box in Job Entry Form.

I am able to have the EpiShape change with the CheckedChanged event. What I would like is to be able to read the value from the field upon opening a job.

I thought EpiViewNotification would be the event to use but I cannot get any results from this.

MechShape = EpiShape
JobHead_UD.DrwMechChk_c = value I need check for my logic

image
image

private void edvJobHead_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.AddRow))
{
if ((args.Row > -1))
{

		Ice.Lib.Framework.EpiShape MechShape = ((Ice.Lib.Framework.EpiShape)csm.GetNativeControlReference("0901396e-f1ac-4960-b4a1-47b8a2272727"));
		EpiDataView edvMech = (EpiDataView)(oTrans.EpiDataViews["JobHead"]);
		Boolean MechBool = (bool)edvMech.dataView[edvMech.Row]["DrwMechChk_c"];
			if (!(MechBool))
			{
			MechShape.Status = (Ice.Lib.Framework.StatusTypes)0;
			}
			else
			{
			MechShape.Status = (Ice.Lib.Framework.StatusTypes)3;
		 }
		}
	}
}

The wizard for the Notification event defaults the “if” statement to epiTransction.NotifyType.AddRow. You probably need to change the AddRow to Initialize,

Also, rather than using (Ice.Lib.Framework.StatusTypes)0, you can use StatusTypes.OK. The status types I’ve used are:
OK: Green
Warning: Yellow
Stop: Red
I know there’s also a Global that is blue, not sure about other StatusTypes.

Kevin Simon

1 Like

Here is a customization export of UD40 form - simple example with edv initialize.
and where I was playing around with checkbox field changes. Might give you some ideas. And if you search this site I think you’ll find several other examples.
UD40Shapes.xml (41.4 KB)

1 Like

Thank you very much.
I would like it to clear when the “Clear Screen” button is pressed on the tool bar, but I can look into that.

Also hoping to get the same colors as the built-in check boxes above it, which i’ll probably just do a EpiShape.Visible = False for the current ones and create new ones with a Light Gray background to toggle visible.

Thanks again.

image

This article helped me when I was trying to decipher toolbars…

This was part of the problem I was having thank you.

Do you think it would be ok to use oTrans.Update() in the EpiNotification event or should I assign a “On Field Change” event? Looks like it is working fine with this code.

I’ll have to check the tracing to see if its saving upon loading or something.

image

Kyle,

You really shouldn’t have to do ANY updates of the database. The shape is simply a control on the screen, it has nothing to do with the database updating. You’ve got this marked solved, so not sure if this is a new issue or not. Here’s how I handle it.

The first set of statements is when you have a row and CheckBox01 is true - you get a green shape. The second set of statements is when you have a row and CheckBox01 is false - you get a yellow shape. The third set of statements is when the args.Row is NOT >-1 - there’s no row on the screen. In that case, you’re hiding the shape.

if ((args.NotifyType == EpiTransaction.NotifyType.Initialize))
{
  if ((args.Row > -1))
  {
    if ( (bool)view.dataView[args.Row]["CheckBox01"] == true ) 
    {
      MechShape.Visible = true;
      MechShape.Status = StatusTypes.OK;
      MechShape.EnabledCaption = "Checkbox Was TRUE";
    }
    else 
    {
      MechShape.Visible = true;
      MechShape.Status = StatusTypes.Warning;
      MechShape.EnabledCaption = "Checkbox Was FALSE";
    }
  }
  else   // there is not an active JobHead row - so hide the shape 
  {
    MechShape.Visible = false;
  }
}

That’s all you need. You don’t need to mess with adapters, change events, etc.

I want database change when the box is checked, oTransUpdate() performs an automatic save after checking. I have it working and deployed now though.
Just wasn’t sure which event I should be using for Save-After-Click.