Need help with an Exists Applicability rule

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
Jaymer
Posts: 2454
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Need help with an Exists Applicability rule

Post by Jaymer »

Screen Shot 2018-11-27 at 1.41.22 AM.png
Screen Shot 2018-11-27 at 1.41.22 AM.png (40.46 KiB) Viewed 9289 times
thx
jaymer...
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
PointsWell
Posts: 1460
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: Need help with an Exists Applicability rule

Post by PointsWell »

My understanding (happy to be contradicted) is that the applicability applies to attributes (and relationships) of the record that makes up that row. Exists by definition relates to another record than the one selected.

If you want the button to disappear on the record selected then it should be a simple

Code: Select all

Region.Backup<>'Y'
You'd need to update the other North records if you create a North backup.

But I may have misunderstood what the question is from the information provided, and I kinda feel that I have.
Jaymer
Posts: 2454
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: Need help with an Exists Applicability rule

Post by Jaymer »

nope
the file starts with 4 records.
you can make a backup of each region, which makes the file grow up to 8 records.

once there is a backup for a region, you cannot backup again ON THAT REGION, so the button has to disappear

you need to do a self join to the table to see if the region is there with a backup flag.
adding another column or changing the process is not valid.
this MUST be done using an Applicability criteria
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
PointsWell
Posts: 1460
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: Need help with an Exists Applicability rule

Post by PointsWell »

You don’t need to add any columns to the grid. If you can describe the relationship to the selected record you should be able to do it.

If your backup process affects all prior North region records (as an example) then you could touch them all when you run the backup
JonP
Posts: 287
Joined: Thu Feb 16, 2017 9:49 pm
Location: United States

Re: Need help with an Exists Applicability rule

Post by JonP »

I don't trust "NOT(EXISTS". In theory it should work, but my experience is it doesn't. You might try...

Code: Select all

COUNT Region WHERE (Region.Backup='Y' AND Region.Value=ThisRegionValue)=0
Also, I can't remember off the top of my head if "This" is supported in an applicability statement or if you need a LIRU attribute.
v8.1 on Windows 10 / MySQL 5.6 (local), v8.1 on Windows Server 2016 / MySQL 5.6 (server)
tford
Posts: 4238
Joined: Sat Mar 10, 2007 6:44 pm

Re: Need help with an Exists Applicability rule

Post by tford »

I'm sure I'm not seeing the whole picture, but don't you want to simply not show the "make backup" option for any Region instance that already has a the case of Region.Backup='Y''?
Tom - V8.8 build 3137 - MySql / PostGres
Jaymer
Posts: 2454
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: Need help with an Exists Applicability rule

Post by Jaymer »

tford wrote:"Do not show the "make backup" option for any Region instance that already has a the case of Region.Backup='Y''?
Tom, yes, thats exactly it... kinda almost.
Like I wrote: "once there is a backup for a region, you cannot backup again ON THAT REGION, so the button has to disappear"
I cannot mark the original record with a "backup made" flag, and then simply hide the button based on that.
I have to derive the existence of that "other" record that may be out there, and hide [make backup] if its found.

PointsWell wrote:You don’t need to add any columns to the grid. If you can describe the relationship to the selected record you should be able to do it.
If your backup process affects all prior North region records (as an example) then you could touch them all when you run the backup
Sean, I have presented a simple example - this is NOT my actual, more complicated case.
I've described the "backup" process - it creates another record for the specified region and sets the backup flag to Y.
You (and I) cannot change that.

Jon - yes! that looked good, but...
Screen Shot 2018-11-27 at 1.37.34 PM.png
Screen Shot 2018-11-27 at 1.37.34 PM.png (13.21 KiB) Viewed 9250 times
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
Jaymer
Posts: 2454
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: Need help with an Exists Applicability rule

Post by Jaymer »

NOTE: Ignore this post - use the example as described in the OP
(this shows the "real" code - but its MUCH simpler to understand based on the example in the OP. No need to decipher this)

FYI:

I simplified the Applicability condition to this (simplified just as a test, this DOES NOT meet the requirements in the OP):
EXISTS UserEmailTemplates WHERE (UserEmailTemplates.ps_Office=LoggedInRegularUser.ps_CurrentOffice)

ERROR:

Code: Select all

Evaluating condition EXISTS UserEmailTemplates WHERE (UserEmailTemplates.ps_Office=LoggedInRegularUser.ps_CurrentOffice)
com.bas.connectionserver.server.BASServerException: Internal error. Invalid expression EXISTS UserEmailTemplates WHERE (UserEmailTemplates.ps_Office=LoggedInRegularUser.ps_CurrentOffice)
NOTE: I know this works in a process, so I don't believe the EXISTS condition is semantically incorrect:

Code: Select all

IF EXISTS UserEmailTemplates WHERE 
		(UserEmailTemplates.ps_Office = Office AND UserEmailTemplates.DRE_Type=RegularUser.TempQry1	) THEN
		FIND UserEmailTemplates WHERE


SO, I INFER
that the culprit must be the EXISTS in the Applicability condition.

Can't do this EXISTS, and can't do a COUNT
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
intra
Posts: 279
Joined: Thu Oct 11, 2012 1:30 pm
Location: Australia

Re: Need help with an Exists Applicability rule

Post by intra »

This is very similar to what i am experiencing on this thread.
https://www.awareim.com/forum/viewtopic.php?f=2&t=10759

I did use the NOT() function to inverse the result however it produces some odd results when validating if an operation shows up on the grid based on the rule.
Avid Linux user....
Post Reply