Show comments default if there is comment if not remove the space of the comment

Certified Senior Developer

Hi Everyone,

 am trying to show the comments history in a card layout to fetch the approval of the stage/comments added by the user /name.

Requirement is to show the comments if user is added, if not need to remove the space of the comment.  Below is my code and condition seems not working..

Thanks to help here and to learn more!

local!isCommentAvailable: a!isNotNullOrEmpty(index(ri!audit['recordType!{77342a51-f497-4d5d-a8e5-d123d13967df}TMA Audit.relationships.{683d367a-af56-4cf5-af48-16fbd40c5dbb}tmaComments.fields.{719d7da1-f969-4e01-85ad-d4ffb6f37778}comments'],1,null)),

  Discussion posts and replies are publicly visible

Parents Reply Children
  • 0
    Certified Senior Developer
    in reply to gayatria0439

    Hi Gayathri, Yes Exactly.  Could you please help with the reference logic here? 

  • 0
    Certified Senior Developer
    in reply to gayatria0439

    Yes, Gayathri exactly. Is it possible to send the reference on this logic to remove the gap if there are no comments added? I appreciate your help.

  • 0
    Certified Associate Developer
    in reply to thanikanti kavitha

    Sure  ,

    We should use a!isNotNullOrEmpty() for the specific item in the comments section. The expression a!isNotNullOrEmpty(fv!item[comment]) will display the comment data if a comment is present; otherwise, it will not display anything. I have handled this using Rich Text and written a showWhen condition to manage the display logic

  • +1
    Certified Associate Developer
    in reply to thanikanti kavitha

    here am adding code for your reference 

    a!localVariables(
      local!commentsData: index(
        a!queryRecordType(
          recordType: 'recordType!{b9769d97-f83d-4c90-b8de-acbc2b678ec5}IM Comments',
          pagingInfo: a!pagingInfo(1,10)
        ),
        "data",
        null
      ),
      {
        a!forEach(
          items: local!commentsData,
          expression: {
            a!cardLayout(
              contents: {
                a!sideBySideLayout(
                  items: {
                    a!sideBySideItem(
                      item: a!imageField(
                        images: a!userImage(
                          user: fv!item['recordType!{b9769d97-f83d-4c90-b8de-acbc2b678ec5}IM Comments.fields.{614925a0-7974-41e8-ba5a-9a65b1f9ddc9}createdBy']
                        ),
                        size: "SMALL",
                        style: "AVATAR"
                      ),
                      width: "MINIMIZE"
                    ),
                    a!sideBySideItem(
                      item: a!richTextDisplayField(
                        labelPosition: "COLLAPSED",
                        value: {
                          a!richTextItem(
                            text: fv!item['recordType!{b9769d97-f83d-4c90-b8de-acbc2b678ec5}IM Comments.fields.{9c0d2338-4f73-418d-9abd-44a043b6b342}name'],
                            size: "STANDARD",
                            style: { "STRONG" }
                          ),
                          char(32),
                          a!richTextItem(
                            text: text(
                              fv!item['recordType!{b9769d97-f83d-4c90-b8de-acbc2b678ec5}IM Comments.fields.{dafb326d-85f8-47b2-b2f8-7a81c564fa48}createdOn'],
                              "hh:MM a"
                            ),
                            color: "SECONDARY",
                            size: "SMALL"
                          )
                        }
                      ),
                      width: "AUTO"
                    ),
                    a!sideBySideItem(
                      item: a!richTextDisplayField(
                        labelPosition: "COLLAPSED",
                        value: {
                          a!richTextIcon(
                            icon: "reply",
                            linkStyle: "STANDALONE",
                            color: "ACCENT"
                          )
                        }
                      ),
                      width: "MINIMIZE"
                    ),
                    a!sideBySideItem(
                      item: a!richTextDisplayField(
                        labelPosition: "COLLAPSED",
                        value: {
                          a!richTextIcon(icon: "ellipsis-v", color: "ACCENT")
                        }
                      ),
                      width: "MINIMIZE"
                    )
                  },
                  alignVertical: "MIDDLE"
                ),
                a!richTextDisplayField(
                  labelPosition: "COLLAPSED",
                  value: {
                    a!richTextItem(
                      text: {
                        "@",
                        fv!item['recordType!{b9769d97-f83d-4c90-b8de-acbc2b678ec5}IM Comments.fields.{b5aad2ad-3aa4-45ab-9905-bc88a186ad25}mentionedName']
                      },
                      color: "ACCENT"
                    ),
                    char(32),
                    a!richTextItem(
                      text: fv!item['recordType!{b9769d97-f83d-4c90-b8de-acbc2b678ec5}IM Comments.fields.{980370d2-5d99-4476-bcc2-867d59c91ec8}comments']
                    )
                  },
                  showWhen: a!isNotNullOrEmpty(fv!item['recordType!{b9769d97-f83d-4c90-b8de-acbc2b678ec5}IM Comments.fields.{980370d2-5d99-4476-bcc2-867d59c91ec8}comments'])
                ),
                a!cardLayout(
                  contents: {
                    a!columnsLayout(
                      columns: {
                        a!columnLayout(
                          contents: {
                            a!cardLayout(
                              contents: {
                                a!richTextDisplayField(
                                  labelPosition: "COLLAPSED",
                                  value: {
                                    a!richTextIcon(
                                      icon: "file-invoice-dollar",
                                      color: "#674ea7",
                                      size: "MEDIUM_PLUS"
                                    )
                                  },
                                  align: "CENTER",
                                  marginAbove: "EVEN_LESS",
                                  marginBelow: "EVEN_LESS"
                                )
                              },
                              height: "AUTO",
                              style: "#d9d2e9",
                              marginBelow: "NONE",
                              showBorder: false
                            )
                          },
                          width: "EXTRA_NARROW"
                        ),
                        a!columnLayout(
                          contents: {
                            a!cardLayout(
                              contents: {
                                a!sideBySideLayout(
                                  items: {
                                    a!sideBySideItem(
                                      item: a!richTextDisplayField(
                                        labelPosition: "COLLAPSED",
                                        value: {
                                          a!richTextItem(
                                            text: {
                                              fv!item['recordType!{b9769d97-f83d-4c90-b8de-acbc2b678ec5}IM Comments.fields.{420479fd-41b7-4fc8-bf9b-f7ec9d9adeb5}claimNumber']
                                            },
                                            style: { "STRONG" }
                                          )
                                        },
                                        preventWrapping: true,
                                        marginBelow: "NONE"
                                      )
                                    ),
                                    a!sideBySideItem(
                                      item: a!tagField(
                                        labelPosition: "COLLAPSED",
                                        tags: {
                                          a!tagItem(
                                            text: fv!item['recordType!{b9769d97-f83d-4c90-b8de-acbc2b678ec5}IM Comments.fields.{f64b0cc0-4b39-4349-ae51-f7b6ac55805c}tagName'],
                                            backgroundColor: "#9db6d0"
                                          )
                                        },
                                        size: "SMALL"
                                      ),
                                      width: "MINIMIZE"
                                    )
                                  },
                                  alignVertical: "MIDDLE",
                                  marginBelow: "NONE"
                                ),
                                a!richTextDisplayField(
                                  labelPosition: "COLLAPSED",
                                  value: {
                                    a!richTextItem(
                                      text: concat(
                                        text(
                                          fv!item['recordType!{b9769d97-f83d-4c90-b8de-acbc2b678ec5}IM Comments.fields.{dafb326d-85f8-47b2-b2f8-7a81c564fa48}createdOn'],
                                          "MMM"
                                        ),
                                        " ",
                                        text(
                                          fv!item['recordType!{b9769d97-f83d-4c90-b8de-acbc2b678ec5}IM Comments.fields.{dafb326d-85f8-47b2-b2f8-7a81c564fa48}createdOn'],
                                          "dd"
                                        ),
                                        ", ",
                                        text(
                                          fv!item['recordType!{b9769d97-f83d-4c90-b8de-acbc2b678ec5}IM Comments.fields.{dafb326d-85f8-47b2-b2f8-7a81c564fa48}createdOn'],
                                          "YYYY"
                                        )
                                      ),
                                      color: "SECONDARY"
                                    )
                                  },
                                  preventWrapping: true,
                                  marginBelow: "NONE"
                                )
                              },
                              link: a!dynamicLink(label: "Dynamic Link", saveInto: {}),
                              height: "AUTO",
                              style: "NONE",
                              marginBelow: "NONE",
                              showBorder: false
                            )
                          }
                        )
                      },
                      alignVertical: "MIDDLE",
                      spacing: "NONE"
                    )
                  },
                  link: a!dynamicLink(),
                  height: "AUTO",
                  style: "NONE",
                  shape: "SEMI_ROUNDED",
                  padding: "NONE",
                  marginAbove: "LESS",
                  marginBelow: "NONE",
                  showBorder: true,
                  showShadow: false
                )
              },
              link: a!dynamicLink(label: "Dynamic Link", saveInto: {}),
              height: "AUTO",
              style: "NONE",
              shape: "ROUNDED",
              padding: "STANDARD",
              marginBelow: "LESS",
              showBorder: false,
              showShadow: true
            )
          }
        )
      }
    )

  • 0
    Certified Senior Developer
    in reply to gayatria0439

    Thanks for the reference code, Gayathri.