# MES Button Customization

**URL:** <https://www.epiusers.help/t/mes-button-customization/37379>\
**Category:** Epicor ERP 10\
**Created:** [February 21, 2017, 5:29pm UTC](https://www.epiusers.help/t/mes-button-customization/37379 "2017-02-21T17:29:06Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![CDP](https://www.epiusers.help/user_avatar/www.epiusers.help/cdp/32/231_2.png) [@CDP](https://www.epiusers.help/u/CDP)\
**Post date:** [February 21, 2017, 5:29pm UTC](https://www.epiusers.help/t/mes-button-customization/37379/1 "2017-02-21T17:29:06Z")

</div>

Hello all.

I have added a customized button to my MES screen to call a Dashboard. That part works well.

Right now I can either make the button inactive all the time or active all the time. What I’d like to do is have the button inactive when MES starts (just like all the other MES buttons) and then become active once someone logs in. Anyone know how to do this?

Charlie Payne  
Hendrick Screen Company  
Owensboro, KY

---

<div class="post-metadata">

**Author:** ![rbucek](https://www.epiusers.help/user_avatar/www.epiusers.help/rbucek/32/28841_2.png) [@rbucek](https://www.epiusers.help/u/rbucek)\
**Post date:** [February 21, 2017, 5:49pm UTC](https://www.epiusers.help/t/mes-button-customization/37379/2 "2017-02-21T17:49:33Z")

</div>

use the wizard to create an event on EpiViewNotification.

enter the code below… change to your button name

```
private void edvEmpBasic_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))
		{
			EnableDisableCustomControls(true);
		}
        else
        {
			EnableDisableCustomControls(false);                             
        }
	}
}

private void EnableDisableCustomControls(bool iFlag)
{
	<yourcontrol>.Enabled = iFlag;
}

```

hth…

---

<div class="post-metadata">

**Author:** ![Chris\_Conn](https://www.epiusers.help/user_avatar/www.epiusers.help/chris_conn/32/93797_2.png) [@Chris\_Conn](https://www.epiusers.help/u/Chris_Conn)\
**Post date:** [February 21, 2017, 5:59pm UTC](https://www.epiusers.help/t/mes-button-customization/37379/3 "2017-02-21T17:59:14Z")

</div>

The way I did it was to use the state of another button that  
activated/deactivated with the same desired permissions.

```cs
//First I got a ref to the button I want to mimic, and set an event on property change (in InitializeCustomCode)
Mtlbtn = (EpiButton)csm.GetNativeControlReference("c06b3700-995a-4f9b-b975-68af8d2acd6d");
Mtlbtn.PropertyChanged += new Infragistics.Win.PropertyChangedEventHandler(PropChange);

private void PropChange(object sender ,Infragistics.Win.PropertyChangedEventArgs args)
{
//Here on prop change, I stole it's style and applied it to my button (TestBtn)
TestBtn.StyleSetName = ((EpiButton)sender).StyleSetName;
TestBtn.BringToFront(); //Did this because my button sits on top of old existing button
}

//Don't Forget to add:
using Infragistics.Win; //at top
Mtlbtn.PropertyChanged -= new Infragistics.Win.PropertyChangedEventHandler(PropChange); //OnDestroyCustom code

```

---

<div class="post-metadata">

**Author:** ![josecgomez](https://www.epiusers.help/user_avatar/www.epiusers.help/josecgomez/32/55731_2.png) [@josecgomez](https://www.epiusers.help/u/josecgomez)\
**Post date:** [February 21, 2017, 6:35pm UTC](https://www.epiusers.help/t/mes-button-customization/37379/4 "2017-02-21T18:35:50Z")

</div>

@Chris_Conn  
 ![](https://epiusers.help/uploads/default/original/2X/5/534be82305f3cd87910361ce97fa59ad96d2ae24.jpg)

That was a hell of a workaround!

---

<div class="post-metadata">

**Author:** ![Chris\_Conn](https://www.epiusers.help/user_avatar/www.epiusers.help/chris_conn/32/93797_2.png) [@Chris\_Conn](https://www.epiusers.help/u/Chris_Conn)\
**Post date:** [February 21, 2017, 6:37pm UTC](https://www.epiusers.help/t/mes-button-customization/37379/5 "2017-02-21T18:37:46Z")

</div>

Well, it works. lol

![](https://epiusers.help/uploads/default/original/2X/a/ab595c7ec16e6e782580961d871d6b41ab630e72.jpg)

---

<div class="post-metadata">

**Author:** ![josecgomez](https://www.epiusers.help/user_avatar/www.epiusers.help/josecgomez/32/55731_2.png) [@josecgomez](https://www.epiusers.help/u/josecgomez)\
**Post date:** [February 21, 2017, 6:38pm UTC](https://www.epiusers.help/t/mes-button-customization/37379/6 "2017-02-21T18:38:41Z")

</div>

![](https://media.giphy.com/media/6pjnF8qE6sqU8/giphy.gif)

I am just teasing you 🙂

---

<div class="post-metadata">

**Author:** ![Chris\_Conn](https://www.epiusers.help/user_avatar/www.epiusers.help/chris_conn/32/93797_2.png) [@Chris\_Conn](https://www.epiusers.help/u/Chris_Conn)\
**Post date:** [February 21, 2017, 6:43pm UTC](https://www.epiusers.help/t/mes-button-customization/37379/7 "2017-02-21T18:43:17Z")

</div>

![](https://epiusers.help/uploads/default/original/2X/3/37e37924b34ec3cf452c04b6b69d2b337e91555d.gif)

I getting emotionally scarred in the Epicor environment. -1 beer from the truck load I owe you.

---

<div class="post-metadata">

**Author:** ![josecgomez](https://www.epiusers.help/user_avatar/www.epiusers.help/josecgomez/32/55731_2.png) [@josecgomez](https://www.epiusers.help/u/josecgomez)\
**Post date:** [February 21, 2017, 6:50pm UTC](https://www.epiusers.help/t/mes-button-customization/37379/8 "2017-02-21T18:50:13Z")

</div>

![](https://epiusers.help/uploads/default/original/2X/7/70aa39b8140090b68b43f9bc7affa8739bded2d6.jpg)

---

<div class="post-metadata">

**Author:** ![Chris\_Conn](https://www.epiusers.help/user_avatar/www.epiusers.help/chris_conn/32/93797_2.png) [@Chris\_Conn](https://www.epiusers.help/u/Chris_Conn)\
**Post date:** [February 21, 2017, 6:51pm UTC](https://www.epiusers.help/t/mes-button-customization/37379/9 "2017-02-21T18:51:52Z")

</div>

😄  
 ![](https://epiusers.help/uploads/default/original/2X/a/a4c6bcef6928d584caf9bf486fa039428b76ed62.gif)

---

<div class="post-metadata">

**Author:** ![rbucek](https://www.epiusers.help/user_avatar/www.epiusers.help/rbucek/32/28841_2.png) [@rbucek](https://www.epiusers.help/u/rbucek)\
**Post date:** [February 21, 2017, 7:02pm UTC](https://www.epiusers.help/t/mes-button-customization/37379/10 "2017-02-21T19:02:37Z")

</div>

![](https://epiusers.help/uploads/default/original/2X/2/2f817f3e87b6bb214e2976c381e316cd33e5ba76.jpg)

---

<div class="post-metadata">

**Author:** ![hkeric.wci](https://www.epiusers.help/user_avatar/www.epiusers.help/hkeric.wci/32/52019_2.png) [@hkeric.wci](https://www.epiusers.help/u/hkeric.wci)\
**Post date:** [February 22, 2017, 12:55pm UTC](https://www.epiusers.help/t/mes-button-customization/37379/11 "2017-02-22T12:55:33Z")

</div>

```
// This is the way MES does it - use this snippet to determine your flag
public bool isLogged
{
    get
    {
        if (this.oTrans.LaborHedView.HasRow && this.oTrans.EmpBasicView.dataView.Count > 0)
            return true;
        else
            return false;
    }
}

```

Also if you want to create the Button the same way MES does - throw something like this, but refactored inside your InitializeCustomCode()

```
this.oTrans.MESControlView.dataView.Table.Columns.Add("UD_MassIssue", typeof(bool));
this.oTrans.MESControlView.dataView.Table.Columns["UD_MassIssue"].ExtendedProperties.Add("MenuID", "XISSUTST");
this.oTrans.MESControlView.dataView.Table.Columns["UD_MassIssue"].ExtendedProperties.Add("MESTab", "XISSUTST");
this.oTrans.MESControlView.dataView[0]["UD_MassIssue"] = false;

RowRule UD_MassIssue = new RowRule("UD_MassIssue", RuleCondition.Equals, false);
UD_MassIssue.AddAction(RuleAction.AddControlSettings(this.oTrans, "MESControl.UD_MassIssue", SettingStyle.ReadOnly));
this.oTrans.MESControlView.AddRowRule(UD_MassIssue);

```

The button will automatically then fire up the specified MenuID - MES will handle it behind the scenes. You will also be able to EpiBind your Button to example UD\_MassIssue - and let the EpiBinding drive the state by managing true/false.

---

<div class="post-metadata">

**Author:** ![EpsilonMaximus68Olds](https://www.epiusers.help/user_avatar/www.epiusers.help/epsilonmaximus68olds/32/16788_2.png) [@EpsilonMaximus68Olds](https://www.epiusers.help/u/EpsilonMaximus68Olds)\
**Post date:** [April 13, 2021, 5:54pm UTC](https://www.epiusers.help/t/mes-button-customization/37379/12 "2021-04-13T17:54:08Z")

</div>

> [@hkeric.wci](#):
>
> ```auto
> public bool isLogged
> {
> get
> {
> if (this.oTrans.LaborHedView.HasRow && this.oTrans.EmpBasicView.dataView.Count > 0)
> return true;
> else
> return false;
> }
> }
> 
> ```

Can you provide any additional help on this? I have gotten everything to work except that it won’t enable the button no matter if I log into MES or not. I used the section for `this.oTrans.MESControlView`.
