Topic
6 replies Latest Post - ‏2012-11-19T12:23:53Z by SystemAdmin
sam.plyler
sam.plyler
12 Posts
ACCEPTED ANSWER

Pinned topic Component rules in type trees

‏2012-11-14T20:52:00Z |
I am trying to make my type tree such that a particular element will only accept two strings. The field is a currency field, and I would only like for it to accept CAD and USD as values. I am unsure of how the logic for this would work through WTX, but what I had in mind was this.

If currency = "CAD" || currency = "USD" then set to that value, else none

I know this is a pretty basic logical statement, but there is hardly any examples on how to use syntax in this program, and I can't figure out how to use the OR operation so that I can test for both CAD and USD from one rule.

Thank you for all help!
Updated on 2012-11-19T12:23:53Z at 2012-11-19T12:23:53Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    6184 Posts
    ACCEPTED ANSWER

    Re: Component rules in type trees

    ‏2012-11-15T08:35:01Z  in response to sam.plyler
    Hello,

    there's no way to "force" an output card to refuse a value based on the type tree.

    If you set a component rule, then you can use the Data Audit Settings and the Audit log to detect the fact that your map created invalid data.

    Another solution could be to use a "reference" series of the allowed values, and accept to map only of the proposed value is in the allowed set.

    Something like

    =IF (MEMBER (SomeData, Currency:Reference), SomeData, FAIL ("Invalid currency : " + SomeData))

    Thinking more about it, this rule does not seem right. I'd rather check the input values and make the data invalid (via a component rule) if they are not in the allowed values.

    Hope this helps.
  • SystemAdmin
    SystemAdmin
    6184 Posts
    ACCEPTED ANSWER

    Re: Component rules in type trees

    ‏2012-11-15T16:06:54Z  in response to sam.plyler
    Another approach is to use a restriction list in your type tree, instead of a component rule.
    • sam.plyler
      sam.plyler
      12 Posts
      ACCEPTED ANSWER

      Re: Component rules in type trees

      ‏2012-11-15T21:36:47Z  in response to SystemAdmin
      I looked into both methods, and it seems that a restriction list is my better option. I followed the instructions I found on another post but I am still getting undesired output. Here is what I tried:

      1) In my properties for the Currency element I set the Restrictions to 'Value', Ignore case to 'No', and Rule to 'Include'.

      2) In the Currency code element I added 'CAD' and 'USD' to there own Include row.

      3) Analyze and save type tree.

      4) Rebuild source before execution

      Is there something I might be missing?
      • SystemAdmin
        SystemAdmin
        6184 Posts
        ACCEPTED ANSWER

        Re: Component rules in type trees

        ‏2012-11-16T07:55:41Z  in response to sam.plyler
        This sounds correct. What exactly is happening when you run the map with invalid data? Have you run the map with trace on?
      • SystemAdmin
        SystemAdmin
        6184 Posts
        ACCEPTED ANSWER

        Re: Component rules in type trees

        ‏2012-11-16T21:15:41Z  in response to sam.plyler
        Not sure we understand each other here. If the restriction list is on the output card's type tree, then nothing can forbid the mapping rules to "force" invalid data through.

        The restriction list and component rules will only work on input (and make data invalid), or help reporting invalid data WAS generated (via data audit)

        Pardon me if this was already what you understood
  • SystemAdmin
    SystemAdmin
    6184 Posts
    ACCEPTED ANSWER

    Re: Component rules in type trees

    ‏2012-11-19T12:23:53Z  in response to sam.plyler
    Sorry for any confusion, I was only trying to answer the question from the original posting:

    "I am trying to make my type tree such that a particular element will only accept two strings. The field is a currency field, and I would only like for it to accept CAD and USD as values."

    This makes no mention of input or output cards, and I was merely suggesting a restriction list (on the INPUT tree) as a simple way to achieve this.

    I guess we interpreted this question differently!