Forum Discussion

ruchi_pandey's avatar
ruchi_pandey
New Contributor II
6 years ago
Solved

How to use "contains" function in router? I am getting error of expression failure

Hi guys,

I am trying to use router with diff data scenarios, where I have to give conditions like:
1)
($DIFF_REC_COUNT<0) && (_PIPELINE_NAME.contains(‘DI_AVT_DH_PERSON_TYPE_ODS’,‘DI_AVT_DH_PERSON_CITIZENSHIP_ODS’,‘DI_AVT_DH_PERSON_LANGUAGE_ODS’))

If its true, goto Success flow or

  1. ($DIFF_REC_COUNT<0) && (_PIPELINE_NAME.contains(‘DI_AVT_DH_PERSON_TYPE_STG’,‘DI_AVT_DH_PERSON_CITIZENSHIP_STG’,‘DI_AVT_DH_PERSON_LANGUAGE_STG’))

goto this flow.

But looks like this expression is not correct; hence I am getting error like:

Failure: Unexpected error occurred while evaluating expression: SC@7e0b949, Resolution: Please check your expression

Please suggest!

  • ruchi_pandey's avatar
    ruchi_pandey
    6 years ago

    I solved this issue actually…
    I gave this exp and it worked.

    ($DIFF_REC_COUNT<0) && (_PIPELINE_NAME.contains(‘PERSON_TYPE_ODS’)|| _PIPELINE_NAME.contains(‘PERSON_CITIZENSHIP_ODS’)|| _PIPELINE_NAME.contains(‘PERSON_LANGUAGE_ODS’) )

    THanks for your quick response though… 🙂

11 Replies

  • with your .contains function, use true or false Boolean values for evaluation, also I am not sure if you can pass multiple arguments in contains function, try the expressions

    1. ($DIFF_REC_COUNT<0) && (_PIPELINE_NAME.contains(‘DI_AVT_DH_PERSON_TYPE_ODS’) == true || _PIPELINE_NAME.contains.(‘DI_AVT_DH_PERSON_LANGUAGE_ODS’) == true)

    2. ($DIFF_REC_COUNT<0) && (_PIPELINE_NAME.contains(‘DI_AVT_DH_PERSON_TYPE_STG’) == true || _PIPELINE_NAME.contains(‘DI_AVT_DH_PERSON_LANGUAGE_STG’) == true)

    • ruchi_pandey's avatar
      ruchi_pandey
      New Contributor II

      I gave this in Expression:
      ($DIFF_REC_COUNT<0)==true &&
      (_PIPELINE_NAME.contains(‘PERSON_TYPE_ODS’,‘PERSON_CITIZENSHIP_ODS’,‘PERSON_LANGUAGE_ODS’,‘OCF_US_ODS’,‘OCF_MEXICO_ODS’,‘OCF_NETHERLANDS_ODS’,‘OCF_COSTA_RICA_STG’)==true)

      And got this error… JSON o/p

      [
      {
      “reason”: null,
      “failure”: “Unexpected error occurred while evaluating expression: SC@3ce966fb”,
      “resolution”: “Please check your expression”,
      “sub-expression”: {
      “0: $DIFF_REC_COUNT”: [
      -2
      ],
      “1: 0”: ,
      “2: <”: [
      true
      ],
      “3: true”: ,
      “4: ==”: [
      true
      ],
      “5: _PIPELINE_NAME”: [
      “DI_AVT_DH_OCF_COSTA_RICA_STG”
      ],
      “6: ‘PERSON_TYPE_ODS’”: ,
      “7: ‘PERSON_CITIZENSHIP_ODS’”: ,
      “8: ‘PERSON_LANGUAGE_ODS’”: ,
      “9: ‘OCF_US_ODS’”: ,
      “10: ‘OCF_MEXICO_ODS’”: ,
      “11: ‘OCF_NETHERLANDS_ODS’”: ,
      “12: ‘OCF_COSTA_RICA_STG’”: ,
      “13: (‘PERSON_TYPE_ODS’,‘PERSON_CITIZENSHIP_ODS’,‘PERSON_LANGUAGE_ODS’,‘OCF_US_ODS’,‘OCF_MEXICO_ODS’,‘OCF_NETHERLANDS_ODS’,‘OCF_COSTA_RICA_STG’)”: [
      {
      “_snaptype_arguments”: {
      “searchString”: “PERSON_TYPE_ODS”,
      “position”: “PERSON_CITIZENSHIP_ODS”,
      “ignored”: “OCF_COSTA_RICA_STG”
      }
      }
      ]
      }
      }
      ]

      • anubhav_nautiya's avatar
        anubhav_nautiya
        Contributor

        can you use the exact expressions which I provided in my previous comments, and see if that works for you, I dont think you can pass multiple arguments in contains method

  • I have seen some solutions here but nothing that is working for me. Here is my issue:

    Looking all thru the expressions library for info on MATCH or CONTAINS I cannot find the right syntax to find this. How do you pull in multiple arguments?

    $field002 in (“88017”,“88067”)

    this works:
    $field002 ==“88017”

    how do i say IN (blah blah)
    and NOT IN (blah blah)

    I am used to sql expressions not Java.

    • bojanvelevski's avatar
      bojanvelevski
      Valued Contributor

      Try the following expression:

      $field002 matches "88017"|"88067"

  • that worked but how do you say does not match? i tried ! and a few different ideas. kept getting errors

    • bojanvelevski's avatar
      bojanvelevski
      Valued Contributor

      Wrap the whole expression in parenthesis and a NOT operator:

      !($field002 matches "88017"|"88067")

  • perfect. these little easy syntax cannot be found in the documentation! the hard ones, yes.