Start a new topic
Answered

Question regarding named queries

We have this kind of setup in the datamodel :

 


We are trying to build a namedQuery for the CostObject where we want to have a list "Persons" that list the names of the related persons, no matter if they are related to a project or to an order.

A CostObject only can be related to a project OR an order. 

We are able to build this as two separate "Multi records expressions", but since they cannot have the same name, we can not call both "Persons". Another possibility would be if you could hide the upper level from the json result, but we have not been able to do this either.

The ProjectPerson and the OrderPerson related to the same Person Entity.

Any suggestions?


Best Answer

Step 1 - I've setup this very simplified model: 


Step 2 - I create in the Name query a Property "Person" : 


This property is calculated with the following Value Expression expression: 

Case when any Orderses has (1=1)  
     then lookup  
                 string_agg PersonID  
                 separated by ','  
                 from Orderses.Person  
            end
else  lookup  
                 string_agg PersonID  
                 separated by ','  
                 from Projects.Person  
      end
end


It allows to extract in a single field the all the persons related by a project or by an order, separated by ','.

I don't think you can fins a solution to calculate a Multi Record Expression (you cannot use SemQL for Multi-record expression).

1 Comment

Answer

Step 1 - I've setup this very simplified model: 


Step 2 - I create in the Name query a Property "Person" : 


This property is calculated with the following Value Expression expression: 

Case when any Orderses has (1=1)  
     then lookup  
                 string_agg PersonID  
                 separated by ','  
                 from Orderses.Person  
            end
else  lookup  
                 string_agg PersonID  
                 separated by ','  
                 from Projects.Person  
      end
end


It allows to extract in a single field the all the persons related by a project or by an order, separated by ','.

I don't think you can fins a solution to calculate a Multi Record Expression (you cannot use SemQL for Multi-record expression).

Login to post a comment