Question with adding tooltip to each of the ID in a text string of ID

Hi everyone, 

My read-only grid has a column storing a text string of IDs, which looks like this 001/002/003/004/005/006, and it was queried from record type 01

I want to add the tooltip, which will show the Client category of each of the ID in the list, the information is stored in record type 02, and I use the ID from record type 01 as reference data to query. So within richTextDisplayField, I set the tooltip parameter like below: 

tooltip: a!forEach(
                    items: split(
                                fv!row[recordType!record01.Id,
                                 "/"
                             ),
                    expression: "Category:" & 
                                a!queryRecordType(
                                        recordType: recordType!record02,
                                        fields: recordType!record02.clientCategory,
                                        filters: a!queryFilter(
                                                        field: 'recordType!record02.Id,
                                                        operator: "=",
                                                         value: tointeger(fv!item)
                                                         ),
                                        pagingInfo: a!pagingInfo(1,1)
                                 ).data[recordType!record02.clientCategory] 
                  )

I expect that when I click each ID, the tooltip will show: Category: Abcdef, instead I got something like this photo:

 

I think it's the forEach () issue, but no idea why it's the issue... Anyone know what the reason is? 

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Hi molly, 

    As it is not a good practice to use the query entity in looping functions. 

    we can query the data at once and then try fetch the details by using wherecontains() and index() functions.

    a!localVariables(
      local!data1:"001/002/003/004",
      local!category:{
        a!map(
          id:"001",
          category:"Category1"
        ),
        a!map(
          id:"002",
          category:"Category2"
        ),
        a!map(
          id:"003",
          category:"Category3"
        ),
        a!map(
          id:"004",
          category:"Category4"
        )
      },
      a!forEach(
        items: split(local!data1,"/"),
        expression: a!richTextDisplayField(
          label: concat(
            "id - ",
            fv!item,
            " | catgeory - ",
            index(local!category,wherecontains(
              fv!item,
              index(local!category,"id",{})
            ),"category",{})
          )
        )
      )
    )

  • Hi Ujjwa!

    I queried the record fields of recordType02 and stored them in a local variable, then refer to your code for the tooltip part. Below is my code. Using forEach() twice looks extra to me too but it won't work if I put forEach() infront of a!richTextDisplayfield so...  

     

    a!localVariables
    (local!category: a!queryRecordType(
                            recordType: recordtype!record02,
                            fields: {recordtype!record02.Id, recordtype!record02.clientCategory}
                            pagingInfo: a!pagingInfo(1,50)
                     ),
     a!gridColumn(
                label: "ID",
                value: if(
                        a!isNullOrEmpty(fv!row[recordtype!record01.Id]),
                        "-",
                        a!richTextDisplayField(
                                        value: a!forEach(
                                                    items: split(
                                                            fv!row[recordtype!record01.Id],
                                                            "|"
                                                            ),
                                                    expression: 
                                                        a!richTextItem(
                                                            text: insert(fv!item, "; ", if(fv!isFirst, null,count(fv!item))),
                                                            link: a!recordLink(
                                                                        label: fv!item,
                                                                        recordType: recordtype!record01,
                                                                        identifier: tointeger(fv!item),
                                                                        openLinkIn: "NEW_TAB"
                                                                    )
                                                        )
                                                ),
                                        tooltip: a!forEach(
                                                    items: split(
                                                            fv!row[recordtype!record01.id],
                                                            "|"
                                                            ),
                                                    expression: concat("Category:",
                                                                        index(local!category, wherecontains(fv!item,index(local!category,"Id",null)),
                                                                       "categoryName",{})
                                                                )
                                                )
                    )   
                   ),
        sortField: recordtype!record01.Id,
        align: "CENTER"
      ),  
    )

    Below is what shows up when I hover my mouse on the ID and it does not look right to me... 

     

    Just some more info about the background: I am creating a grid column that shows the ID in recordType01, and I want each ID within the list of ID (text string: "001/002/003/004") has seperate tooltip showing it's client category, which data is available in recordType02. the 2 record Types have ID as common column.

Reply
  • Hi Ujjwa!

    I queried the record fields of recordType02 and stored them in a local variable, then refer to your code for the tooltip part. Below is my code. Using forEach() twice looks extra to me too but it won't work if I put forEach() infront of a!richTextDisplayfield so...  

     

    a!localVariables
    (local!category: a!queryRecordType(
                            recordType: recordtype!record02,
                            fields: {recordtype!record02.Id, recordtype!record02.clientCategory}
                            pagingInfo: a!pagingInfo(1,50)
                     ),
     a!gridColumn(
                label: "ID",
                value: if(
                        a!isNullOrEmpty(fv!row[recordtype!record01.Id]),
                        "-",
                        a!richTextDisplayField(
                                        value: a!forEach(
                                                    items: split(
                                                            fv!row[recordtype!record01.Id],
                                                            "|"
                                                            ),
                                                    expression: 
                                                        a!richTextItem(
                                                            text: insert(fv!item, "; ", if(fv!isFirst, null,count(fv!item))),
                                                            link: a!recordLink(
                                                                        label: fv!item,
                                                                        recordType: recordtype!record01,
                                                                        identifier: tointeger(fv!item),
                                                                        openLinkIn: "NEW_TAB"
                                                                    )
                                                        )
                                                ),
                                        tooltip: a!forEach(
                                                    items: split(
                                                            fv!row[recordtype!record01.id],
                                                            "|"
                                                            ),
                                                    expression: concat("Category:",
                                                                        index(local!category, wherecontains(fv!item,index(local!category,"Id",null)),
                                                                       "categoryName",{})
                                                                )
                                                )
                    )   
                   ),
        sortField: recordtype!record01.Id,
        align: "CENTER"
      ),  
    )

    Below is what shows up when I hover my mouse on the ID and it does not look right to me... 

     

    Just some more info about the background: I am creating a grid column that shows the ID in recordType01, and I want each ID within the list of ID (text string: "001/002/003/004") has seperate tooltip showing it's client category, which data is available in recordType02. the 2 record Types have ID as common column.

Children
No Data