How to set ReadOnly Extended Property if another field ReadOnly == true/false

In Order Entry we’re replacing the NeedBy and ShipBy dates (don’t ask -_-) with UD Fields and building custom functionality for them. On the Line Detail tab the original dates will grey out/read only if there’s more than 1 release. I’d like to duplicate this functionality on our UD field dates.

Rather than rebuild the wheel to make sure these dates are always greyed out when they should be, I’d think it would be easier to say “If this field on this data view is read only, so are you”. Unfortunately I’m struggling with this. Getting the value of the extended property seems to be more difficult than it looks and I’m not finding the answer. Not as easy as
if(view.dataView.Table.Columns[“RequestDate”].ExtendedProperties[“ReadOnly”] == true)…

ideas? I think a Rule is the way to set it but the implementation is evading my attempts.

Hello Bendan,

Well I am still curious of why you do not use the originals… :wink:
For our use I am detecting the date change in NeedbyDate, then I read on the customer table the number of days is necessary so the customer will receive on time. Say it is 2, I substract 2 days to the NeedByDate and set the RequestedDate with that value.

I am also detecting (like you for UD fields ) if TotalReleases of the line is more than 1, then I set those fields to readonly as this:
if ( ((int)edvOrderDtl.dataView[edvOrderDtl.Row][“TotalReleases”]) > 1 )
{
edvOrderDtl.dataView.Table.Columns[“PPC_c” ].ExtendedProperties[“ReadOnly”] = true;
}
hope this helps…

and that works for me.

1 Like

Thanks Pierre. We’re looking to do something similar to that using ShipVias. We also (and here’s the frustrating part) want dates driven from the top down instead of the bottom (Rels) up. So no line dates after the header date, and no rel dates after the line dates. Which is the opposite of how it works now. So instead of fighting the functionality, we’re using new fields instead and overwriting the base fields so the base functionality doesn’t fight back. Fun huh?

I was originally going to calculate Releases and set it like you do, but how are you detecting that? It seemed like I’d have to fire that code on every EpiNotification type. Is it easier?

When you change your dates in the summary (top), don’t you get a message asking if the change affect all releases ? (so all the botom dates will become the same?)

Yep, it is under EpiNotification…Initialize

Ah Initialize.

Yes we get that notification but it only seems to affect ones that match. Not ones that have been changed to ship earlier or later, which we want to keep inside certain guidelines. Only moving them under certain circumstances which I didn’t detail. Its a lot. And for multi-release-line dates the line date is based off the earliest release and we wanted the opposite. So as to say, ‘By THIS date every release will have shipped’ instead of ‘We start shipping releases on this day until we’re done’. Seemed cleaner to just start fresh.

Well… Now the Read Only property won’t work right.

Under Initialize I can get through the code all the way down to where I say “Make it read only” and have a messagebox reading it all back to me. Yet it doesn’t work. I have the exact syntax you have with the right dataview name.

If I just set it in SetExtendedProperties to be read only all the time it correctly greys out that field. So I know that code works. But it refuses to work in the EpiNotification set. Cleared Cache and all that. Do I need to do something different for the EpiDataView variable?

private void edvOrderDtl_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
{
	if ((args.NotifyType == EpiTransaction.NotifyType.Initialize))
	{
		if ((args.Row > -1))
		{
			//MessageBox.Show("Test" + ((int)view.dataView[view.Row]["TotalReleases"]).ToString(), "Read Only Releases", MessageBoxButtons.OK, MessageBoxIcon.Error);
		
			try
			{
				if( ((int)view.dataView[view.Row]["TotalReleases"]) > 1)
				{
					//MessageBox.Show("Yup " + ((int)view.dataView[view.Row]["TotalReleases"]).ToString(), "Read Only Releases", MessageBoxButtons.OK, MessageBoxIcon.Error);
					view.dataView.Table.Columns["ShipBy_c"].ExtendedProperties["ReadOnly"] = true;
					view.dataView.Table.Columns["NeedBy_c"].ExtendedProperties["ReadOnly"] = true;
				}...
1 Like

Hey Brendan,

I didn’t quite get if you changed your approch, but instead of looking for .ExtendedProperties[“ReadOnly”]==true you might as well simply look for the TextBox…?

if(this.epiTextBoxC1.ReadOnly){
MessageBox.Show(“Yes it is”, “It is read only”, MessageBoxButtons.OK, MessageBoxIcon.Error);
} else {
MessageBox.Show(“No it is not”, “It is not read only”, MessageBoxButtons.OK, MessageBoxIcon.Error);
}

setting the extended properties probably still should be done by using the extended properties…
Simply create the method and based on the Event run the code.

Marlon

Hi Marlon, I did change my approach to more like what Pierre had. Setting the Control itself was my next thing to try. I’m just confused why the Set Extended Properties works in one spot but not another. Weird.

Hi @BrendanW @Hogardy

Did either of you ever get this working properly?
I am having exactly the same issue. I need to set the read only property of a field conditionally on a checkbox.

I have a AfterFieldChanged event which fires my notification event

Then i have an on notification event setup to fire the extended properties update

This seems to work as i can see the value updates to true, however there is no change to the field on the front end. What am i missing here? do i need to notify the detail view again that the extended property has been updated?

Hi Jordan. Did you ever figure this one out? We have a similar requirement for a custom textbox on OrderHed, and would love to not have to disable the field since it’s just there for info purposes, and the greyed out text is just too hard to read.

There are lots of issues in many of the classic screens where Epicor will override you when you try to set fields Read Only (either with code or in the Properties settings).

The one thing that I’ve been able to rely on over the years is Row Rules. They always seem to do the trick. Sometimes I will even put a Row Rule condition of something like “1=1” so that the condition is always true.

Thanks for jumping in, Tom. I setup a RowRule to make the field ReadOnly if it is not null. Here’s the auto-generated code:

	private void CreateRowRuleOrderHedFreightTerms_cNotEqual_Constant_NullValue()
	{
		// Description: Set Freight Terms ReadOnly
		ControlSettings controlSettings1EpiReadOnly = new ControlSettings();
		controlSettings1EpiReadOnly.SetStyleSetName("EpiReadOnly");
		RuleAction epireadonlyOrderHed_FreightTerms_c = RuleAction.AddControlSettings(this.oTrans, "OrderHed.FreightTerms_c", controlSettings1EpiReadOnly);
		RuleAction[] ruleActions = new RuleAction[] {
				epireadonlyOrderHed_FreightTerms_c};
		// Create RowRule and add to the EpiDataView.
		RowRule rrCreateRowRuleOrderHedFreightTerms_cNotEqual_Constant_NullValue = new RowRule("OrderHed.FreightTerms_c", RuleCondition.NotEqual, "Constant: NullValue", ruleActions);
		((EpiDataView)(this.oTrans.EpiDataViews["OrderHed"])).AddRowRule(rrCreateRowRuleOrderHedFreightTerms_cNotEqual_Constant_NullValue);
	}

Unfortunately, I am still able to modify the text, so I don’t think it’s quite there yet.

I think you actually need to use the “Disabled” style instead of “EpiReadOnly”. Disabled in Row Rules is not the same as the Disabled property of the control; it should give you the ReadOnly appearance that you’re looking for.

Or, if the field should always be read only, you can set that in Extended Properties and it should stick.