@If variant for aliases

For a computed text I needed to write down the value of a dialoglist field which uses aliases.

Luckily the number of options was limited, but for a list of long options I do not want to use this construction:

@If( condition1 ; action1 ; condition2 ; action2 ; … ; condition99 ; action99 ; else_action )

Therefor I came up with the following solution creating a text-list with options and then go through them using @Elements, @Right and @Left:

“Awaiting Approval|1”:

@For(n := 1;n <= @Elements(status); n := n+1;

4 thoughts on “@If variant for aliases

  1. Stephan H. Wissel 2007-October-25 / 9:42 am

    Hi Patrick,

    you have some more options… If you use a hidden field that hold the status values (like statusselection) you could make your computed field a keyword field too drawing the values from statusselection.

    Otherwise try this (no for loop required):

    rightvalue := @Right(status;”|”);
    leftvalue := @Left(status;”|”);

    or short:

    🙂 stw

  2. quintessens 2007-October-25 / 10:52 am

    Hej Stephan,

    thanks for the suggestion

  3. Thomas Bahn 2007-October-25 / 6:31 pm

    I like Stephan’s solution (a I use it myself 😉 ).

    But back to your approach:

    leftvalue is uninitialized, if Tx_Status is not in your status list.

    Instead of


    you could simply exit the loop by


    and replace the last line (leftvalue) by the else_action, e. g. “-1” for undefined.

  4. Tommy Valand 2007-October-28 / 5:47 pm

    I made a post a little while back about “Keyword/Value lookup fields”, where I emulate an associative array in formula. I think this technique could also fit well into this area.

    status :=
    ”Draft” : “0″:
    “Awaiting Approval” : “1″:
    “Approved” : “2″:
    “Archived” : “3″:
    “Rejected” : “91″:
    “Returned” : “92″;

    text := status[ @Member( Tx_Status ; status ) – 1 ]

    My post if you’re interested: http://dontpanic82.blogspot.com/2007/10/keywordvalue-lookup-fields.html

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s