Condition on a list of objects

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
srufini
Posts: 33
Joined: Thu May 23, 2019 11:23 pm

Condition on a list of objects

Post by srufini »

Hello,

I am trying an elegant way to create a condition for which all objects that are subitems of another objects satisfy a condition. For example

I want to check if there are any "Approval" objects that are parts of "DocIssue.Approvals" and have their Status as "Requested" or "Approved"

This is how I wrote the condition, but it doesn´t seem to work:

Code: Select all

COUNT Approval  WHERE ((Approval IN ThisDocIssue.Approvals) AND Approval.Status IN 'Requested','Approved' )>0
Thanks in advance for any help/Suggestion.

Sergio
himanshu
Posts: 722
Joined: Thu Jun 19, 2008 6:24 am
Location: India
Contact:

Re: Condition on a list of objects

Post by himanshu »

Hi,

Your condition looks ok... just try to remove the inner brackets like below and make sure ThisDocIssue is present in the context.
COUNT Approval WHERE (Approval IN ThisDocIssue.Approvals AND Approval.Status IN 'Requested', 'Approved') > 0
From,
Himanshu Jain


AwareIM Consultant (since version 4.0)
OS: Windows 10.0, Mac
DB: MYSQL, MSSQL
srufini
Posts: 33
Joined: Thu May 23, 2019 11:23 pm

Re: Condition on a list of objects

Post by srufini »

Thanks for the quick answer.
I tried but still no luck.
I create in the form of the object DocIssue an HTML section where I copied this text to check the calculation.
I have 3 approvals in the DocIssue opened in this form and a total of 5 Approvals in the whole application.

Code: Select all

DocIssue ID: <<DocIssue.ID>> <br>
<<COUNT Approval WHERE (Approval.Status='New')>><br>
<<COUNT Approval WHERE (Approval.ParentObject.ID=ThisDocIssue.ID)>><br>
<<COUNT Approval WHERE (Approval.ParentObject.ID=ThatDocIssue.ID)>><br>
<<COUNT Approval WHERE (Approval.ParentObject.ID=DocIssue.ID)>><br>
<<COUNT Approval  WHERE (Approval IN DocIssue.Approvals)>><br>
<<COUNT Approval WHERE (Approval IN ThisDocIssue.Approvals)>><br>
The result is:
Line 1)= 120 (the actual ID -> correct)
Line 2)= 5 (the total number of approvals in the business application)
Line 3)= 0
Line 4)= 0
Line 5)= 0
Line 6)= 0
Line 7)= 0


seems a very specific and stupid mistake. What am I doing wrong?

Thanks
customaware
Posts: 2391
Joined: Mon Jul 02, 2012 12:24 am
Location: Ulaanbaatar, Mongolia

Re: Condition on a list of objects

Post by customaware »

Have you tried this....

COUNT Approval WHERE (Approval IN ThisDocIssue.Approvals AND (Approval.Status='Requested' OR Approval.Status='Approved'))>0

Depending on Context.... you may not need ThisDocIssue especially if DocIssue has been passsed as an input
Cheers,
Mark
_________________
AwareIM 6.0, 8.7, 8.8, 9.0 , MariaDB, Windows 10, Ubuntu Linux. Theme: Default, Browser: Arc
Upcloud, Obsidian....
Image
srufini
Posts: 33
Joined: Thu May 23, 2019 11:23 pm

Re: Condition on a list of objects

Post by srufini »

Hi,

yes, still doesn´t work. The point is that does not even work the counting with one condition only:

COUNT Approval WHERE (Approval IN DocIssue.Approvals )
This always returns 0 either with "This" or not. But in the form I can clearly see the Approvals that are part of the object.attribute -> DocIssue.Approvals and there are 3!
customaware
Posts: 2391
Joined: Mon Jul 02, 2012 12:24 am
Location: Ulaanbaatar, Mongolia

Re: Condition on a list of objects

Post by customaware »

I have PM'd you
Cheers,
Mark
_________________
AwareIM 6.0, 8.7, 8.8, 9.0 , MariaDB, Windows 10, Ubuntu Linux. Theme: Default, Browser: Arc
Upcloud, Obsidian....
Image
Post Reply