Forum Discussion

Walter Fuentes's avatar
Walter Fuentes
Copper Contributor
Jun 08, 2020

Link to a lookup a column by using json formatting

I want to create a link to a lookup a column by using json formatting, but the coding is not accepted to be applied. What I expect is to select a link in the list “Invoice” and be transferred to the list “invoice items” and get the specific record by ID…

I have created a column called “invoice” in the list “Invoice items” as vlookup to list “Invoice” column ID.

 

Here are the lists that I have.

List1: Invoice

Fields: Invoice Number, due date, invoice date, invoice item.

 

List2: Invoice Items

Fields: Quantity, Price, Total, Invoice.

                                                                                                                                       

Please let me know any feedback.

3 Replies

  • Walter Fuentes : Lookup field any way take you to the original list item from the current list item. It's by default gives link to the item in another list.

     

    Even though following is the code I tried and it worked:

    {
    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "a",
    "txtContent": "@currentField.lookupValue",
    "attributes": {
    "href": {
    "operator": "+",
    "operands": [
    "/sites/Test21/Lists/TestList/DispForm.aspx?ID=",
    "@currentField.lookupId"
    ]
    },
    "target": "_blank"
    },
    "style": {
    "color": "#796BB1",
    "font-weight": "bold"
    }
    }

    • Walter Fuentes's avatar
      Walter Fuentes
      Copper Contributor

      HiAshish_Kohale 

      Thanks for supporting me with this request, I still need your help, I am not familiar with this feature.


      1. By using the script the text or link in the column disappear.

      2.Not sure how use "@currentField.lookupId", if I put it exactly the same this will makes blank my text or link in the column, and I use "Invoice.lookupId" this will take me to an empty display form.

       

      Thanks my friend.

Resources