How to show expression when a record is empty in entity

How to show expression when a record is empty in entity

  

I have a overview page with a list of products that are in the Product entity. On this page I want to show a expression with a warning text telling the user that there are products in the DB with missing specs. I already have the expression with an If statement (see picture) but it doesn't work quite well. It only checks the latest added products and not the whole entity and all its records. How can I achieve this? It needs to check all the rows on null and empty

hi Celik,

I think you need to concatenate all the rows:

missing_specs = " "

if null... then missing_specs = missing_specs + Getproducts.List.Current.Product.ID


regards,

A



Hi Oghuzan,

First, every time you refer to an item of a list, you are referring to a single element of the list, not the entire list.
This is the case here, as the expression in the page, being built before the list itself, and using the "Current", will look only for the first item in the list returned by the aggregate/sql you are using as source to the Table Records in the screen.

In your case, if you want to warn the user that there are records with missing values, in ANY record of the list, as you are using pagination (good choice), you need to do a separate query to find this.

I would use an extra agregate, almost a copy of the one you're using to populate the Table Records, but with a set of extra filters to return ONLY the records where there is something missing, like addign this:

Product.Kleur = NullTextIdentifier()
OR
Product.Leverancier = NullTextIdentifier()
OR
...
OR
Product.BestHoeveelhide = NullIdentifier()

Then, in the expression, I would put it inside an if, where the condition would be simply GetProducts.Empty (where GetProducts is the name of this extra aggregate)

Cheers,
Eduardo Jauch

Thank you for your help. I did exactly as you told me to. I made an extra aggregate below the inital aggregate. Named this new aggregate: GetProductsFilteredMissing.

In the expression on the page I entered "GetProductsFilteredMissing.Emtpy" but it gives an error. What am I doing wrong. Sorry if it's a noob question, I am a student and we are supposed to build an application without any courses on Outsystems, very frustrating.





Eduardo Jauch wrote:

Hi Oghuzan,

First, every time you refer to an item of a list, you are referring to a single element of the list, not the entire list.
This is the case here, as the expression in the page, being built before the list itself, and using the "Current", will look only for the first item in the list returned by the aggregate/sql you are using as source to the Table Records in the screen.

In your case, if you want to warn the user that there are records with missing values, in ANY record of the list, as you are using pagination (good choice), you need to do a separate query to find this.

I would use an extra agregate, almost a copy of the one you're using to populate the Table Records, but with a set of extra filters to return ONLY the records where there is something missing, like addign this:

Product.Kleur = NullTextIdentifier()
OR
Product.Leverancier = NullTextIdentifier()
OR
...
OR
Product.BestHoeveelhide = NullIdentifier()

Then, in the expression, I would put it inside an if, where the condition would be simply GetProducts.Empty (where GetProducts is the name of this extra aggregate)

Cheers,
Eduardo Jauch



Hi Oghuzan,

How is supposed to a person to do something without learning how to use the tools to do this thing? :o

In any case, please, show the error message and how are you building this extra aggregate.
If you want (and can), you can attach the OML so wew can take a look.

Cheers,
Eduardo Jauch

In the pictures below you can see that I made an new aggregate with the filter(picture1). The filter works because it shows the 2 products that meet the filter requirements (picture2). On the picture 3 you can see the expression with the if statement that gives the error. 

(You have to click right mouse button and open the images in a different tab to see the whole image haha.)



Hi Oghuzan,

How is supposed to a person to do something without learning how to use the tools to do this thing? :o

In any case, please, show the error message and how are you building this extra aggregate.
If you want (and can), you can attach the OML so wew can take a look.

Cheers,
Eduardo Jauch



Hi Oguzhan,

If you are typing the expression, after you press the dot (.) Service Studio will show you a list of available options. "Empty" is not amongst them, so the error is that you typed something not available. Also, instead of typing, you can select from the "Scope" tree below, just expand GetProductsFilteredMissing.

Empty is a property of a List. A query itself is not a list, hence it doesn't have an Empty. It does have a List however, so the full expression should be GetProductsFilteredMissing.List.Empty.

Another hint: as you are only interested in the distinction between Empty and not Empty, limit the query output to a single record, by setting the Aggregate's Max. Records property to 1. In case you have lots of empty records, this will speed up things.

Hi,

Sorry for the typo (should have put the LIST).
Killian already found the issue and give a good hint on using the Max set to 1 (it will improve the query in database).

Cheers,
Eduardo Jauch

Yes you are right, list.empty does work! but it's not what I'm trying to achieve, It's not about empty records but I want to show the expression IF there is an emtpy atribute in one of the records of the whole entity.

For example, i have 300 products in the product entity and a product has a Name, Size, Color. If one of those atributes is emtpy or null I want to show the expression.


Kilian Hekhuis wrote:

Hi Oguzhan,

If you are typing the expression, after you press the dot (.) Service Studio will show you a list of available options. "Empty" is not amongst them, so the error is that you typed something not available. Also, instead of typing, you can select from the "Scope" tree below, just expand GetProductsFilteredMissing.

Empty is a property of a List. A query itself is not a list, hence it doesn't have an Empty. It does have a List however, so the full expression should be GetProductsFilteredMissing.List.Empty.

Another hint: as you are only interested in the distinction between Empty and not Empty, limit the query output to a single record, by setting the Aggregate's Max. Records property to 1. In case you have lots of empty records, this will speed up things.



Just use Not GetProducts.List.Empty :)

EDIT:

OR keep the condition as it is and put the expression in the False branch of the IF.

P.S. You really should do the online training. Life would be much easier ;)

Yes got it!! "Not" works, or putting it in the false branch works too.

I also understand how it works now! The second aggregate filters the list and if there are now empty attributes, it returns a empty list. 

Now I just need to make a "filter" button which filters the list and only shows the record which have empty attributes in them on the overview page.Maybe you can help me in the right direction??

Eduardo Jauch wrote:

Just use Not GetProducts.List.Empty :)

EDIT:

OR keep the condition as it is and put the expression in the False branch of the IF.

P.S. You really should do the online training. Life would be much easier ;)



Solution

I would use a local or session variable (boolean), named, for example, ShowOnlyRecordsWithMissingValues, , initially set to false, and add the following filter to the main aggregate (that shows the list in the screen):

  ShowOnlyRecordsWithMissingValues = False
  OR
  Product.Kleur = NullTextIdentifier()
  OR
  Product.Leverancier = NullTextIdentifier()
  OR
  ...
  OR
  Product.BestHoeveelhide = NullIdentifier()

This way, you will turn on/off the filter by missing fields based on this variable.
Than it is a matter of activate or deactivate this variable in the interface (maybe a checkbox).

Cheers,
Eduardo Jauch


Solution

Amazing! it worked! both problem solved in an hour thanks to the help I got here from you guys!


Eduardo Jauch wrote:

I would use a local or session variable (boolean), named, for example, ShowOnlyRecordsWithMissingValues, , initially set to false, and add the following filter to the main aggregate (that shows the list in the screen):

  ShowOnlyRecordsWithMissingValues = False
  OR
  Product.Kleur = NullTextIdentifier()
  OR
  Product.Leverancier = NullTextIdentifier()
  OR
  ...
  OR
  Product.BestHoeveelhide = NullIdentifier()

This way, you will turn on/off the filter by missing fields based on this variable.
Than it is a matter of activate or deactivate this variable in the interface (maybe a checkbox).

Cheers,
Eduardo Jauch




You're welcome :)