Need edit the Paragraph field when click on Edit button

Hello All,

I have the below requirement.

In section layout I need give the paragraph field for comments sections. Initially it should be show in a read only.

I need to put edit button after the comments field when click on Edit button it should come as blank and when enter the new comment it should be over written the previous comment (Initial comments will already be there as an integration with other tool). 

When update the new comment in DB it should over write the previous comment.

If you provide with code that would be really helpful.

Thanks in advance.

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    The one hint I can easily provide for you here is that you should use local variables (i always recommend that people use local variables extremely liberally to help abstract on-form functionality, data, etc).  In this case you would declare a variable at the beginning i.e. "local!enableCommentEditing" with a value of false(), which you will then also set as either the "disabled" or "readOnly" setting on your paragraph field (per your preference), and toggle this value to true with the click of your desired button/link/whatever.  You can handle the overwriting of the original comment text either in an additional "saveInto" of the button, or in the saveInto of the editable paragraph, depending on the finer details of your use case - there's no "one right way" here.

    Further I would suggest you invest some time in practicing how on-form elements work together in various ways, just in general, because even a use case this seemingly complicated should be fairly easy to implement for someone with enough practice.  One thing I like to do personally, which helped me learn both when I was new as well as with ongoing new functionality -- is to think of a new use case (like yours here), then develop a "test" / "fake" interface just for myself, where I experiment and try to accomplish the goal, with the help of the Appian Functions Documentation (among others) where I'm not sure how to accomplish certain key pieces.  Additionally, it is then a lot easier for us on the forum to provide meaningful feedback to questions that are more specific in nature and/or ones where you have a code sample and screenshots of what you've tried and what isn't working for you.

  • As an example of Mike's suggestion (which I would recommend as well):

    a!localVariables(
      local!enableCommentEditing: false,
      local!CDT: {comments: "initial comments here"}, /* This will be a rule input with your comments! */
      
      {
        a!paragraphField(
          label: "Comments",
          value: local!cdt.comments,
          saveInto: local!cdt.comments,
          readOnly: not(local!enableCommentEditing),
          required: local!enableCommentEditing
        ),
        a!buttonArrayLayout(
          align: "START",
          buttons: {
            a!buttonWidget(
              label: "Edit",
              disabled: local!enableCommentEditing,
              value: true,
              saveInto: {
                local!enableCommentEditing,
                a!save(local!CDT.comments,null)
              }
            )
          }
        )
      }
    )

  • 0
    Certified Associate Developer
    in reply to Chris

    hi ,chis 

    what if what we have multiple comments in a for each . but i want to edit the same on loogedinUser basis. 

  • hi ,chis 

    what if what we have multiple comments in a for each . but i want to edit the same on loogedinUser basis. 

    I would suggest to start your own thread, likely your scenario is different and this thread is a few years old.  Add some details on your use case and we are happy to take a look.