Updating Extended properties after InitializeCustomCode has no effect?

On InitializeCustomCode I set the line description to be ready only. This updates the UI and disables editing the description as I would expect. Then I have a button that toggles the read only state:

	private void epiButtonC1_Click(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here **
		EpiDataView edvQuoteDtl = ((EpiDataView)(this.oTrans.EpiDataViews["QuoteDtl"]));
		edvQuoteDtl.dataView.Table.Columns["LineDesc"].ExtendedProperties["ReadOnly"] = !(bool)edvQuoteDtl.dataView.Table.Columns["LineDesc"].ExtendedProperties["ReadOnly"];
		MessageBox.Show(edvQuoteDtl.dataView.Table.Columns["LineDesc"].ExtendedProperties["ReadOnly"].ToString());
	}

The message box displays true, false, true, false as you keep clicking it, as I would expect. But the UI does not reflect that at all, it stays in the same state it started in.

Do I have to manually tell it to refresh somehow?

after updating your code on the UI, clear your cache, log off/on, go to the Customization Maintenance BO, and search and select it, then run a verification process.

Do an EpiView Notification after setting the property

1 Like

you could try to notify the data objects of the change:
oTrans.NotifyAll();

Update: dammit Jose, beat me

I tried the oTrans.NotifyAll(); that @Chris_Conn suggested, that didn’t do the trick. How do I do a EpiView Notification ?

_edvUD01.Notify(new EpiNotifyArgs(this.oTrans, this._edvUD01.Row, this._edvUD01.Column));

But if a NotifyAll doesnt work, I doubt an explicit notify will work

That’s using a cannon to kill a mosquito, however it should work… :thinking:
Single view notify is as follows, give it a shot.

 edvQuoteDtl.Notify(new EpiNotifyArgs(oTrans, edvQuoteDtl.Row, EpiTransaction.NotifyType.Initialize);

Still not updating… I cleared client cache and closed and re-opened epicor to be sure. I know the read only value is being set correctly, because when I click the “Description” button by the actual description field to open the larger editor it allows/disallows editing based off what the message box said. But the text box remains disabled…

Here is all of the code in the customization…

// **************************************************
// Custom code for QuoteForm
// Created: 8/28/2018 3:59:38 PM
// **************************************************

extern alias Erp_Contracts_BO_QuoteDtlSearch;
extern alias Erp_Contracts_BO_Quote;
extern alias Erp_Contracts_BO_Customer;
extern alias Erp_Contracts_BO_AlternatePart;
extern alias Erp_Contracts_BO_Part;
extern alias Erp_Contracts_BO_Vendor;
extern alias Erp_Contracts_BO_VendorPPSearch;
extern alias Erp_Contracts_BO_ShipTo;

using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Erp.Adapters;
using Erp.UI;
using Ice.Lib;
using Ice.Adapters;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;

public class Script
{
	// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
	// Begin Wizard Added Module Level Variables **

	private EpiDataView edvQuoteDtl;
	private EpiBaseAdapter oTrans_adapter;
	// End Wizard Added Module Level Variables **

	// Add Custom Module Level Variables Here **

	public void InitializeCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
		// Begin Wizard Added Variable Initialization


		// End Wizard Added Variable Initialization

		// Begin Wizard Added Custom Method Calls

		SetExtendedProperties();
		this.epiButtonC1.Click += new System.EventHandler(this.epiButtonC1_Click);
		// End Wizard Added Custom Method Calls
	}

	public void DestroyCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
		// Begin Wizard Added Object Disposal


		this.epiButtonC1.Click -= new System.EventHandler(this.epiButtonC1_Click);
		// End Wizard Added Object Disposal

		// Begin Custom Code Disposal

		// End Custom Code Disposal
	}

	private void SetExtendedProperties()
	{
		// Begin Wizard Added EpiDataView Initialization
		EpiDataView edvQuoteDtl = ((EpiDataView)(this.oTrans.EpiDataViews["QuoteDtl"]));
		// End Wizard Added EpiDataView Initialization

		// Begin Wizard Added Conditional Block
		if (edvQuoteDtl.dataView.Table.Columns.Contains("LineDesc"))
		{
			// Begin Wizard Added ExtendedProperty Settings: edvQuoteDtl-LineDesc
				edvQuoteDtl.dataView.Table.Columns["LineDesc"].ExtendedProperties["ReadOnly"] = true;
			// End Wizard Added ExtendedProperty Settings: edvQuoteDtl-LineDesc
		}
		// End Wizard Added Conditional Block
	}

	private void epiButtonC1_Click(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here **
		EpiDataView edvQuoteDtl = ((EpiDataView)(this.oTrans.EpiDataViews["QuoteDtl"]));
		edvQuoteDtl.dataView.Table.Columns["LineDesc"].ExtendedProperties["ReadOnly"] = !(bool)edvQuoteDtl.dataView.Table.Columns["LineDesc"].ExtendedProperties["ReadOnly"];
		this.oTrans.NotifyAll();
		MessageBox.Show(edvQuoteDtl.dataView.Table.Columns["LineDesc"].ExtendedProperties["ReadOnly"].ToString());
		edvQuoteDtl.Notify(new EpiNotifyArgs(oTrans, edvQuoteDtl.Row, EpiTransaction.NotifyType.Initialize));
	}
}

Well when in doubt use a bazooka

ControlSettings cs = new ControlSettings();
cs.IsEnabled = true;
cs.IsReadOnly = false;
 
view.SetCurrentRowPropertyManually("EmailJT_c", cs);

Note this “overrides” everything so put it “back” when you are done with it… its on you

2 Likes

OK, closer. so I am using this code:

		ControlSettings cs = new ControlSettings();
		cs.IsEnabled = !(bool)edvQuoteDtl.dataView.Table.Columns["LineDesc"].ExtendedProperties["ReadOnly"];
		cs.IsReadOnly = (bool)edvQuoteDtl.dataView.Table.Columns["LineDesc"].ExtendedProperties["ReadOnly"];
 
		edvQuoteDtl.SetCurrentRowPropertyManually("LineDesc", cs);

It toggles the read only for the button and not the textbox… Also what do you mean by put it back? Do I just need to store something in a variable and restore it later or what?

EDIT: Looks like I would have to call EpiDataView.ClearManualRowProp(columnName); – anything else?

have you verify your customization as i suggested ?

I just ran that. It doesn’t find any problems, except it doesn’t like the position of my test button.

check the stated properties for your field there?

OK, that code does what I want if I use another field, like JobComment. But when I use the LineDesc it only enables and disables the button. How can I make it disable/enable the textbox?

It should just work assuming the text box is EpiBound to the same field. With that said, why would it disable the button? Are you sure you are referencing the right field?

1 Like

The EpiBinding for the button is QuoteDtl.DescriptionButton and the EpiBinding for the textbox is QuoteDtl.LineDesc.

Yet this code makes the button appear enabled/disabled:

		ControlSettings cs = new ControlSettings();
		cs.IsEnabled = !(bool)edvQuoteDtl.dataView.Table.Columns["LineDesc"].ExtendedProperties["ReadOnly"];
		cs.IsReadOnly = (bool)edvQuoteDtl.dataView.Table.Columns["LineDesc"].ExtendedProperties["ReadOnly"];
		edvQuoteDtl.SetCurrentRowPropertyManually("LineDesc", cs);

That’s weird - you could try to bash it by explicitly setting your grid/field or control to readonly manually.

This is not a fix to the problem, but it may help. One thing I’ve gotten in the habit of doing is putting a version number in the title bar. So, something like “Order Entry v1.1”. That way, when you make a change, you can update the version number. If you open the customization or a user calls you, it’s real easy to ask what the version number shows and find out whether they (or you) are running the current version or if you’ve got caching issues.

Kevin Simon

3 Likes

Great suggestion - cache\version issues can be tedious

I don’t think its a cache issue. I have exported and attached it below if anyone has time to look at it.
CMCustomization_Evans_Readonly_Test_App.QuoteEntry.QuoteForm.xml (13.3 KB)