Skip to main content
Best answer by davidj137213

Use this code....

a!localVariables(
  
  local!text: " The local variable to use when evaluating the given expression. Use the 'local!' domain to define and reference individual variables. By default, a local variable will automatically update when any variables it references are changed. To change the way variables are updated, use the a!refreshVariable() function. Variables can be refreshed under the following conditions: after each reevaluation, periodically on an interval, or when other variables change.",
  
  local!result:if(
    condition: len(local!text)>50,
    valueIfTrue: concat({left(local!text, 50),  " (more...)"}),
    valueIfFalse: local!text
  ),
  
  local!result
  
)

4 replies

mikes0011
Brainy
March 27, 2024

https://docs.appian.com/suite/help/24.1/Appian_Functions.html  -> "text"

The standard primitive function for text length is simply "len()".

For read-only text displays with such a length cut-off, you can simply use the Rich Text Display Field and in cases where the length is greater than 50, show the left("my text", 50) characters of it, then "(more)" - what's better, with the Rich Text Display Field you can then make just the "(more)" tag clickable and expand the displayed text to show the entire thing.  I've used this trick in grids where a column has text that sometimes gets too long for comfortable display by-defult.

davidj137213
March 27, 2024

Use this code....

a!localVariables(
  
  local!text: " The local variable to use when evaluating the given expression. Use the 'local!' domain to define and reference individual variables. By default, a local variable will automatically update when any variables it references are changed. To change the way variables are updated, use the a!refreshVariable() function. Variables can be refreshed under the following conditions: after each reevaluation, periodically on an interval, or when other variables change.",
  
  local!result:if(
    condition: len(local!text)>50,
    valueIfTrue: concat({left(local!text, 50),  " (more...)"}),
    valueIfFalse: local!text
  ),
  
  local!result
  
)

konduruc733182
March 27, 2024

A sample code to acheive that. Just replace the data  and limit with rule inputs and you can re-use.

a!localVariables(
  local!data: "A good example of a paragraph contains a topic sentence, details and a conclusion. 'There are many different kinds of animals that live in China. Tigers and leopards are animals that live in China's forests in the north. In the jungles, monkeys swing in the trees and elephants walk through the brush. There are camels in the deserts in China that people use for transportation. Lots of different kinds of animals make their home in China",
  a!richTextDisplayField(
    value: {
      a!localVariables(
        local!showMore: false,
        {
          a!richTextItem(
            text: if(
              local!showMore,
              local!data,
              left(local!data, 50)
            )
          ),
          char(32),
          a!richTextItem(
            link: a!dynamicLink(
              value: if(local!showMore, false, true),
              saveInto: local!showMore
            ),
            text: if(local!showMore, "..less", "..more"),
            showWhen: len(local!data) > 50
          )
        }
      )
    }
  )
)

karumurua531442
March 28, 2024

Hi [mention:6f76e3d598b24878a92b669865896c18:e9ed411860ed4f2ba0265705b8793d05]  you find the logic directly in the patterns tab in interface design tab, you can change the logic as per your requirement