Skip to main content
hema.mathivathanan
July 18, 2023
Question

hardcode values in paragraph field

  • July 18, 2023
  • 7 replies
  • 0 views

Hi, 

I have a paragraph field. I need to hardcode a value, with the below code, the user can change the value. When I used the a!richtextdisplayfield, I was getting an error. 

Can someone pls guide here. 

a!paragraphField(
label: "Rejection Comment",
value: "REJECTION " & local!comment,
saveInto:  local!comment,
)

    7 replies

    July 18, 2023

    Hi, 
    not sure what you are trying to accomplish. The issue with the above approach is, every time the user is interacting with the field, the word 'Rejection' will be added to the content of the field.

    I see no issue with a rich text display field.

    a!localVariables(
      local!comment,
      {
        a!paragraphField(
          label: "Rejection Comment",
          value: "REJECTION " & local!comment,
          saveInto: local!comment,
          
        ),
        a!richTextDisplayField(
          label: "Rich Text Display Field ",
          value: a!richTextItem(
            text: "REJECTION " & local!comment,
            style: "EMPHASIS",
            size: "MEDIUM_PLUS",
            color: "ACCENT"
          )
        )
      }
    )

    mikes0011
    Brainy
    July 18, 2023
    When I used the a!richtextdisplayfield

    because a!richTextDisplayField() is a read-only component.

    value: "REJECTION " & local!comment,

    So if you were trying to make it a READ-ONLY paragraph field, this would be an OK way to DISPLAY the value.  However it's a bit more tricky if you want the text to show up in the field as a default but then save only the user input that follows that value - because, when "REJECTION " is included in the "value" field, that text populates into the user entry, and then it flows to the saveInto when the user changes the value of the field, so any time the user touches it, it'll save a redundant "REJECTION " at the front of the message.

    There are ways around this involving manual work inside the saving, but honestly I fear it's just going to cause more confusion.

    This makes me ask though, why the redundant "REJECTION" label *inside* the field value?  What's wrong with using the... "label" as the label?  What value does it add to have the word again?

    The Expression Guru
    hema.mathivathanan
    July 18, 2023

    It's a requirement where we have "Rejection" followed by where the user can enter text. If I give value: "rejection" & local!comment, the user can delete the word "Rejection" or make changes to it. But, I need it to stay the same.

    Do we have a way to do it

    stefanhelzle0001
    Brainy
    July 18, 2023

    Why not just add that word on submit?