How to check if there is no record returned?

My server action "GetPersonDetail" returns an output of type PersonBasicInfo (contains 2 attributes namely FullName and ContactNumber) and takes in an input variable "IdentityCardNumber" of type text.

If no person is found, the output will be blank. PersonBasicInfo does not contain a Count attribute.

In this case, which built-in function should i use to check if the output is blank? 

Hi,

You can check in the Aggregate GetPersonDetail.Empty, there is a Count attribute too. But, in OutSystems “Empty” is used  

https://success.outsystems.com/Documentation/11/Reference/OutSystems_Language/Data/Handling_Data/Queries/Aggregate


Best regards,

Leandro. 

No no Leandro, the GetPersonDetail is my own server action. It does not return a count. The output variable is not a type of Entity hence there is no default Count or Empty properties. The output variable is a user-defined structure named PersonDetail.

Sorry, I misunderstood! 

You can verify if the attributes is NulltextIdentifier(). 

Fullname = NullTextIdentifier()

Solution

Since Fullname is a Text, not an TextIdentifier, Fullname = "" should be used.

Solution

Hi ,

You can check if Fullname equals "" (empty string) and depending on the type of the contact number, if it is text you can also check if it is equal to "" (empty string) or 0 (zero, in the case the contact number is a integer).

Hope it helps,

If you can change the Server Action, return another output parameter to indicate if data was found, like Empty (boolean) and younset its value inside the action. 

This way you make a clearer eay to identify if there is info or not. 

Cheers 

Eduardo Jauch wrote:

If you can change the Server Action, return another output parameter to indicate if data was found, like Empty (boolean) and younset its value inside the action. 

This way you make a clearer eay to identify if there is info or not. 

Cheers 

Is there a built-in method to check for empty? Something like IsEmptyRecord( )?


In structures don't exist a method to check if is empty. As Eduardo said you have to change the Server Action and return another output parameter to indicate if the structure is empty 

EnthusiaticNewbie wrote:

Eduardo Jauch wrote:

If you can change the Server Action, return another output parameter to indicate if data was found, like Empty (boolean) and younset its value inside the action. 

This way you make a clearer eay to identify if there is info or not. 

Cheers 

Is there a built-in method to check for empty? Something like IsEmptyRecord( )?


No.

You need to check your source (inside the Server Action) and chose an attribute that tells you if there is a result or not. If you are fetching data with Aggregate, the IDs are the ideal, as they will be NullIdentifier() or NullTextIdentifier() if your source does not return anything.

Otherwise, you have to check other attributes and compare against the default value (like "" is a string).

Cheers