Skip to main content
rishukumarg1965
January 31, 2024
Question

input :- test1 : "CRIS3-AB; CRIS3-AB; ; ; SOECS; SOECS; ; ",test2 : "; ; Related FOX; Related FOX; ; ; Trace; Trace", Desire output : " CRIS3-AB;CRIS3-AB;Related FOX; Related FOX; SOECS; SOECS; Trace; Trace"

  • January 31, 2024
  • 9 replies
  • 0 views

There are 2 local variable:

local!test1 : "CRIS3-AB; CRIS3-AB; ; ; SOECS; SOECS; ; ",

local!test2 : "; ; Related FOX; Related FOX; ; ; Trace; Trace",

If no value available before semicolon symbol of local!test2 then a value from local!test1 should take place

Desire output : " CRIS3-AB;CRIS3-AB;Related FOX; Related FOX; SOECS; SOECS; Trace; Trace"

    9 replies

    stefanhelzle0001
    Brainy
    January 31, 2024

    I am not sure how your description matches the desired output, but I got some code to share:

    a!localVariables(
      local!test1 : "CRIS3-AB; CRIS3-AB; ; ; SOECS; SOECS; ; ",
      local!test2 : "; ; Related FOX; Related FOX; ; ; Trace; Trace",
    
      local!test1Splits: split(local!test1, ";"),
      local!test2Splits: split(local!test2, ";"),
      if(
        a!isNullOrEmpty(local!test2Splits[1]),
        a!update(
          local!test2Splits,
          1,
          local!test1Splits[1]
        ),
        local!test2
      )
    )

    rishukumarg1965
    January 31, 2024

    Shon this error :

    Interface Definition: Expression evaluation error [evaluation ID = I48HU] : An array of components may only contain components. Received Text at index 1. 

    stefanhelzle0001
    Brainy
    January 31, 2024

    Again, I am not sure what you are looking for and you initial ask lacks any level of details and context. My recent podcast episode might be of interest for you: https://appian.rocks/2023/12/20/episode-13-how-to-get-your-questions-answered/

    The code snippet is an expression rule, and will not work in an interface.

    abhayd3663
    February 2, 2024

    If you can elaborate more on the usecase we might be able to provide alternative solutions.

    rishukumarg1965
    February 5, 2024

    [mention:3e057f937069479fb3712d1807f826e3:e9ed411860ed4f2ba0265705b8793d05] The issue is resolved now[emoticon:33306c418930400bac28808410f8ac8b]

    abhayd3663
    February 5, 2024

    Good to know!

    jayaprakashr0001
    Participating Frequently
    February 5, 2024

    Hi [mention:c7ed152842da4892ba88b9d946100b8f:e9ed411860ed4f2ba0265705b8793d05] ,

    You can try this code

    a!localVariables(
      local!test1 : "CRIS3-AB; CRIS3-AB; ; ; SOECS; SOECS; ;",
      local!test2 : "; ; Related FOX; Related FOX; ; ; Trace; Trace",
      local!array1:reject(fn!isnull,split(local!test1,";")),
      local!array2:reject(fn!isnull,split(local!test2,";")),
      a!forEach(
        items: enumerate(length(local!array1))+1,
        expression: if(
          a!isNotNullOrEmpty(trim(local!array1[fv!index])),
          local!array1[fv!index],
          local!array2[fv!index]
        )
      )
    )