Community

Connect with us and enhance your M-Files experience using Unitfly Toolkit for M-Files. Here’s how to get started.

Notifications
Clear all

[Solved] Extension Kit: Extended Auto Properties - Ternary Operator Expressions / Concat with seperators

0
Topic starter

Hey Folks

Im looking for a solution to solve the generic "every class should have a concated properties Name or Title"-Problem.

Right now im using one Extended Auto Properties rule per class like 

{Name} | {Hour} | {Price} | {Date}

 

Problem / Feature Request

If a property is empty  its like "Daniel | 3 | | 11.10.2023".

Im basically missing a SQL function called concat_ws (with separator). This function returns a string resulting from the concatenation, or joining, of two or more string values in an end-to-end manner. It separates those concatenated string values with the delimiter specified in the first function argument.

CONCAT_WS ( separator , argument1 , argument2 [ , argumentN ] ... )

  • INPUT: SELECT CONCAT_WS('|', '1 Microsoft Way', NULL, NULL, 'Redmond', 'WA', 98052)
  • OUTPUT: 1 Microsoft Way|Redmond|WA|98052

 

Questions

If I take a look into the documentation i almost found a solution:

https://toolkitformfiles.unitfly.com/documentation/auto-properties/#ternary-operator

Request If property (Project) is empty, then don’t show it
Input <<‘%PROPERTY_1038%’=?’%PROPERTY_1040%’:’%PROPERTY_1038% – %PROPERTY_1040%’>>

First, I think the red marked " is an error, right?

Second: Is it possible to use several of these (like for every property im concating?)

Third: Am I allowed to use {Name} instead of %PROPERTY_xxx%?

 

Regards

Daniel

 

3 Answers
0

Unfortunately, currently, there are 2 possible workarounds (until our team develops these proposed work items):

1. Save properties from other data types to property/ies of Text data type. Then with that work on the Property Operations module. I believe this could be temporary, but it is possible.

2. solution would be using Auto Properties with the ternary operator expressions. 

    You can use nested expressions in Auto Properties.

    Example for "{Name} | {Hour}":

    <<'{Name}'=''?'{Hour}':'<<'{Hour}'=''?'{Name}':'{Name} | {Hour}'>>'>>

    This expression would mean:

    IF {Name} is empty
        THEN write {Hour}
    ELSE
        IF {Hour} is empty
          THEN write {Name}
      ELSE write {Name} | {Hour}

    This could get really complicated when you increase the number of parameters. But you can also help yourself by creating multiple rules with different search filters.

1

Problem / Feature Request

The described use case can be solved using Property Operations and its text function "Concatenate"

https://imgur.com/a/oqljoEQ

The only setback is that, currently, you can only add properties of data types Text or Text (multi-line) as parameters.

 

Additionally, the "Concatenate" expression is available in Auto Properties, but it does not include adding a separator between properties, you can only add different properties:

<<CONCATENATE(<text1>,<text2>)>>

We've created work items for our developers to:

  • Enable using properties of different data types in Property Operations
  • Enable adding separators in Auto Properties expressions "Concatenate"

, and we will contact you as soon as these changes are developed.

Questions

First: Unfortunately, we had problems with quotation marks in our documentation, but all of that should be fixed now.

Second: Yes, it is possible to combine multiple expressions into one, but for your use case I would not recommend it as it could be really complex due to the large number of possibilities

Third: Yes, you are allowed to use {} instead of %PROPERTY_xx%

 

0
Topic starter

Posted by: @viktorzagajski

The only setback is that, currently, you can only add properties of data types Text or Text (multi-line) as parameters.

Are there any workarounds because I need integers as well as dates and of course some single list values. Would it be possible to use other operators to get text back?

regards

Daniel

Answer

WATCH THE WEBINAR

Introducing AI Document Kit: Add-on for AI-driven Document Management