Skip to main content
Completed

Provide code example when creating an Expression, Calculated or Calculation (Function) column

Related products:Software Factory
  • August 30, 2022
  • 8 replies
  • 277 views

Mark Jongeling
Administrator
Forum|alt.badge.img+23

When creating a table column that has a calculation type, it is necessary to write some code. Based on the type, the structure of the code will be different from one and other. Such like Expression columns, you can make use of the “T1.” alias, which is the table itself, whilst Calculated columns cannot use this.

Just like the code example in Control procedure for SQL-typed CP's, I would like a short example that shows me as a developer what I can (and cannot) use as code.  

Example: 

  • Expression: 
    concat_ws(' ', t1.first_name, t1.last_name)  --Thanks @Robbert :)

     

  • Calculated:
    (100.0 + tax_percentage) / 100.0

     

  • Calculated (function): 
    select sum(order_total) from sales_order where sales_order_id = @sales_order_id

     

8 replies

Robert Jan de Nie
Thinkwise blogger
Forum|alt.badge.img+7

Great idea! I always get the proxy function wrong! 


Robbert van Tongeren
Thinkwise blogger

Great!
1 small addition: instead of

concat(t1.first_name, ' ' + t1.last_name)

I would use

concat_ws(' ',t1.first_name,t1.last_name)

Because the concat_ws will already exclude null values with the seperator. :)


Jeroen van den Belt
Administrator
Forum|alt.badge.img+10
NewOpen

Arie V
Community Manager
Forum|alt.badge.img+12
  • Community Manager
  • August 31, 2022

Great idea indeed!


Jeroen van den Belt
Administrator
Forum|alt.badge.img+10
OpenOn the backlog

Mark Jongeling
Administrator
Forum|alt.badge.img+23
  • Author
  • Software Architect
  • July 14, 2023
On the backlogWorking on it!

Mark Jongeling
Administrator
Forum|alt.badge.img+23
  • Author
  • Software Architect
  • July 14, 2023
Working on it!Next release
 

To explain the subtle differences between the query structure for calculated field types, a code example will be added to the query field when using a calculation type for a column. Switching between calculated field types will overwrite the present example if possible.

Image

 
 
 
 

Jeroen van den Belt
Administrator
Forum|alt.badge.img+10
Next releaseCompleted