Skip to main content
rishukumarg1965
Known Participant
Jan 31, 2024 2:20 PM UTC
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"

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
    Jan 31, 2024 2:31 PM UTC

    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
    Known Participant
    Jan 31, 2024 2:39 PM UTC

    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
    Jan 31, 2024 2:42 PM UTC

    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
    Brainy
    Feb 2, 2024 5:29 PM UTC

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

    rishukumarg1965
    Known Participant
    Feb 5, 2024 7:10 AM UTC

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

    abhayd3663
    Brainy
    Feb 5, 2024 5:47 PM UTC

    Good to know!

    jayaprakashr0001
    Participating Frequently
    Feb 5, 2024 9:15 AM UTC

    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]
        )
      )
    )