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

(Brendan Woodell) #1

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.

(Pierre Hogue) #2

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.

(Brendan Woodell) #3

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?

(Pierre Hogue) #4

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

(Brendan Woodell) #5

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.

(Brendan Woodell) #6

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);
				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;

(Marlon Morawetz) #7

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…?

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.


(Brendan Woodell) #8

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.