How to show comments according to user role?

A Score Level 1

Using a grid I display several rows of comments on a form. The requirement is that users should be able to see only their comments or final approval/rejection comments. They should not have visibility to the comments for the different approval flows. The current solution is showing every comment in a grid. Is there any way I can restrict the visibility of approval flow comments? Any recommendations? TIA

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    I hope you have a hierarchy of groups set up that generally define a user's role(s).  In this way it's pretty straightforward to use on-form logic to check whether the viewing user is in certain group(s).  Then you'd use additional on-form logic to simply decide whether different columns (or different comment types, presuming you have a systematic way to differentiate them) are shown for members of different groups.

  • 0
    A Score Level 1
    in reply to Mike Schmitt

    a!localVariables(
      local!commentsPageInfo: a!pagingInfo(
        startIndex: 1,
        batchSize: 10,
        sort: a!sortInfo(field: "createddate", ascending: true)
      ),
      local!commentsData: todatasubset(
        arrayToPage: ri!savedComments,
        pagingConfiguration: local!commentsPageInfo
      ),
      a!sectionLayout(
        label: "Comments",
        
        contents: {
          a!gridField(
            emptyGridMessage: "No Comments Found",
            data: local!commentsData,
            pagingSaveInto: local!commentsPageInfo,
            columns: {
              a!gridColumn(
                label: "Comment",
                sortField: "text",
                value: fv!row.text,
                width: "WIDE"
              ),
              a!gridColumn(
                label: "User",
                sortField: "createdby",
                value: fv!row.createdby
              ),
              a!gridColumn(
                label: "Date Created",
                sortField: "createddate",
                value: fv!row.createddate
              )
            }
          ),
          a!paragraphField(
        label: " Add Comments",
            value: ri!initalComment,
            saveInto: {
              ri!initalComment,
              a!save(ri!userComment, loggedInUser())
            },
            
          )
        }
      )
    )

    This is how the code looks and is called in the main interface.

  • 0
    Certified Lead Developer
    in reply to Tan18

    Seems like you transport the comment in a process from one form to the other. In this case, you will need to implement a filter on your ri!savedComments. I would recommend using the filter() function in combination with a separate expression. Others might prefer to filter using foreach(). Both works, but this is what you need to do.

Reply Children