Rule to calculate length of String

rule to calculate length of a string. if the length of string exceeds 50, then show the access text with (...more.) else returns the sring.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer

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

Reply
  • 0
    Certified Senior Developer

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

Children
No Data