Add record link to each part of a text string

Hi Appian Community,

I have added into my interface a grid as shown below, which was called from a record type. 

ID     relateTo Column 3 Column 4
001 003/004
002 007/004/005
003 001/002/006
004
005
006
007

This is the code that I wrote for column 2 (relatedTo) but didn't work. I used split () to split each row into an array of text IDs, then trying to add link to each of that ID. 


a!richTextItem(
     text: split(fv!row[recordtype.relatedTo], "|"),
     link:  a!forEach(
              items: split(fv!row[recordtype.relatedTo], "|"),
              expression: a!recordLink(
                                       label: fv!item,
                                       recordType: recordType,
                                       identifier: fv!item,
                                       openLinkIn: "NEW_TAB"
        )

    )

)


I want to add link to each ID in column 2 (ID that related to ID in column 1), so when I click any in that text string, I can be directed to the record for that certain ID. I think the identifier needs to be specific but not sure how to do it.

Thanks for your help, and appologise if the code is confusing...

  Discussion posts and replies are publicly visible

  • 0
    Certified Senior Developer

    Hi,

    How about having the richTextItem in the loop?
    Let me make it more clear for you.

    you can have the richTextItem in the loop and add link to each text item you get out of the loop.

    Then the code would look this way.

    a!forEach(
      items: split(fv!row[recordtype.relatedTo], "|"),
      expression: a!richTextItem(
        text: fv!item,
        link: a!recordLink(
          label: fv!item,
          recordType: recordType,
          identifier: fv!item,
          openLinkIn: "NEW_TAB"
        )
      )
    )


    Please try it out!

  • Thanks for the guidance, It looks correct but somehow didn't work for me. I guess because I have the a!gridField outside of the code? I tried 2 ways but both failed...

    a!gridColumn(
          label: "Related To",
          value: a!forEach(
                                items: split(fv!row['recordType.Related To], "|"),
                                expression: if(
                                              IsBlank(fv!row['recordType.relatedTo]),
                                              "-",
                                              a!richTextItem(
                                                       text: fv!item,
                                                       link: a!recordLink(
                                                       label: fv!item,
                                                       recordType: recordType,
                                                       identifier: fv!item,
                                                       openLinkIn: "NEW_TAB"
                                                      )
                                                 )
                                            )                                     

                                     ),
          sortField: fv!row['recordType.Related To],
          align: "CENTER"
     ),

    Another way:

    a!gridColumn(
           label: "Related To",
           value: if(
                      IsBlank( fv!row['recordType.relatedTo]),
                      "-",
                      a!forEach(
                              items: split(fv!row[recordtype.relatedTo], "|"),
                              expression: a!richTextItem(
                                                           text: fv!item,
                                                           link: a!recordLink(
                                                                            label: fv!item,
                                                                            recordType: recordType,
                                                                            identifier: fv!item,
                                                                            openLinkIn: "NEW_TAB"
                                                                            )
                                                   )
                        ),
            sortField: recordType,
            align: "CENTER"
    ),

  • 0
    Certified Senior Developer
    in reply to mollyn126

    Could you please share how the data is present in relatedTo column of your record type?

  • 955|2870|303

    This is one row of the relatedTo column, which data type is text, and the IDs are seperated by "|" 

  • 0
    Certified Lead Developer
    in reply to mollyn126

    You said it did not work. What really did not work? The link is not showing up? it is showing up but not clickable? It is clickable but is not taking you to the correct screen? 

  • 0
    Certified Senior Developer
    in reply to mollyn126

    How are you referring the record fields?
    I hope you are using recordType!.

    Or can you share the exact code by any chance?

  • 0
    Certified Senior Developer
    in reply to mollyn126

    Can you please try this code for gridColumn?

    a!gridColumn(
      label: "Relate To",
      value: if(
        a!isNullOrEmpty(fv!row[recordType.field]),
        "-",
        a!forEach(
          items: split(fv!row[recordType.field], "|"),
          expression: a!richTextItem(
            text: fv!item,
            link: a!recordLink(
              label: fv!item,
              recordType: recordType,
              identifier: tointeger(fv!item),
              openLinkIn: "NEW_TAB"
            )
          )
        )
      )
    )


  • Really appreciate your help but it did not work either, to be honest by looking at the code I thought it will certainly work...