LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  \"Optional\" Parameter Validation

    Employee
    Posted 05-21-2008 17:33

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: johnpelz

    Is there a way turn off the parameter "pre-validation" in a node using a BRAINScript expression?

    For example, we have a paramter that we want to be optional in a sort node for kind of dynamic sort approach (additional sort keys); however, the following will cause a validation error if the parameter is left blank:

    if ("{{^SORT_KEYS^}}".trim().len() > 0) and "{{^SORT_KEYS^}}".isNotNull() then
    AMOUNT
    else
    list(AMOUNT, {{^SORT_KEYS^}})

    Any ideas? Node is posted below:

    node:Sort
    bretype:core::Sort
    editor:sortkey=4834520d63f712a4
    input:@40fd2c743ebf4304/=Head.42fbf39e14aa2417
    output:@40fd2c746a2a3b47/=
    prop:CompareOrderExpr=<<EOX
    if ("{{^SORT_KEY^}}".trim().len() > 0) and "{{^SORT_KEY^}}".isNotNull() then
    AMOUNT
    else
    AddrString
    EOX
    prop:SORT_KEY=A
    editor:XY=760,140
    editor:propdef=SORT_KEY|string|1||None
    end:Sort


  • 2.  RE: \"Optional\" Parameter Validation

    Employee
    Posted 05-21-2008 17:42

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: mmarinelli

    Yes, you can set defaults for parameters which will be evaluated when the parameters are not populated. In your case, use {{^SORT_KEYS=^}} to have the parameter default to an empty string.


  • 3.  RE: \"Optional\" Parameter Validation

    Employee
    Posted 05-22-2008 13:36

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: tczotter

    Mark is right. You should always be thinking about what to use if a value is not filled in, when you invoke textual substitution.

    This allows each request to supply an appropriate default value - they may not all be the same.

    Another approach is to actually put a value into the base node, so all instances inherit a default.

    In this case, however, you intend for the default to be the empty string. There is a special representation for this. Set the initial default value of the parameter (not the request for the parameter, the parameter itself) to the value

    {{^^}}

    That sequence is the BRE equivalent to the statement "this space intentionally left blank" which satisfies the requirement that it is, in fact, not blank.


  • 4.  RE: \"Optional\" Parameter Validation

    Employee
    Posted 07-01-2015 08:27

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: dstacey

    Hi,

    I tried the above to allow for an optional parameter (e.g. Field = {{^SORT_KEYS=^}}) and it works great when I directly leave the node parameter blank - but I want the node parameter to be able to optionally inherit from a global parameter (say GLOBAL_KEY) which in turn I want to be able to leave optionally blank. Now when I leave GLOBAL_KEY blank I still get the "Parameter GLOBAL_KEY not defined" error when I execute the Field = {{^SORT_KEYS=^}} instruction.

    How might I solve this?

    Many thanks,
    Dave


  • 5.  RE: \"Optional\" Parameter Validation

    Employee
    Posted 07-02-2015 00:18

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Tim Meagher

    Can you post an example graph showing the problem you are having?
    Attached is an example of what I *think* you are trying to do, but I'm not sure.
    Attachments:
    GlobalKeys.brg


  • 6.  RE: \"Optional\" Parameter Validation

    Employee
    Posted 07-02-2015 06:41

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: dstacey

    Tim,

    Your graph captures exactly what I am trying to do - when I tried it I only had the reference {{^GLOBAL_KEY}} in my composite rather than {{^GLOBAL_KEY=^}}.

    Thanks,
    Dave