Calculated column formula and conditions into JSON Formatting

cooltechie-5986 1 Reputation point
2023-06-01T16:17:02.5+00:00
=IF(New<>"",
   IF(CID="",
IF(New,"Uploading...",""),"<a href='#' class='cascadingLink' onclick='openInDialog(700,950,true,true,true,""/sites/TW/Reviews/Reviews/Forms/EditForm.aspx?ID="&CID&""");'>Edit Review</a>"),"")

where "New" and "CID" are the list columns



I would like to replicate above calculated formula into JSON Column formatting. Please advise. I am new to JSON Column formatting and not very familiar with Schema.

SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,790 questions
{count} votes

3 answers

Sort by: Most helpful
  1. cooltechie-5986 1 Reputation point
    2023-06-02T15:50:30.1333333+00:00
    1. If NEW Not equal to empty, then, check if CID = Empty and if CID is empty and New is not equal to empty, then Show the text "Uploading.." otherwise, show blank.

    2.If New is not empty, and CID has a value, then show the hyperlink

    3.Otherwise leave it empty.

    0 comments No comments

  2. Ling Zhou_MSFT 15,240 Reputation points Microsoft Vendor
    2023-06-05T09:32:26.0966667+00:00

    Hi @

    Here is the Josn:

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "div",
      "style": {
        "box-sizing": "border-box",
        "padding": "0 2px",
        "overflow": "hidden",
        "text-overflow": "ellipsis"
      },
      "children": [
        {
          "elmType": "div",
          "txtContent": "=if([$New]!='' ,if([$CID]=='',if([$New],'Uploading...',''),''),'')"
        },
        {
          "elmType": "a",
          "attributes": {
            "target": "_blank",
            "href": "='/sites/TW/Reviews/Reviews/Forms/EditForm.aspx?ID='+[$CID]"
          },
          "txtContent": "=if([$New]!='',if([$CID]!='','Edit Review',''),'')"
        }
      ]
    }
    

    Here is the test of my result (The column type of Result is Hyperlink):enter image description here



    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  3. Ling Zhou_MSFT 15,240 Reputation points Microsoft Vendor
    2023-06-06T09:08:19.99+00:00

    Hi @cooltechie-5986,

    Here is the Josn for SharePoint 2019:

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "div",
      "style": {
        "box-sizing": "border-box",
        "padding": "10px 0px",
        "overflow": "hidden",
        "text-overflow": "ellipsis"
      },
    "children":[
    {
    	"elmType": "div",
    	"txtContent" : {
    	 "operator":"?",
    	 "operands":[
    	    {
    			"operator": "!=",
    			"operands": [
    				"[$New]",
    				""
    			]
            },
    		{
    		 "operator":"?",
    		 "operands":[
    		 {
    		  "operator":"==",
    		  "operands": [
    				"[$CID]",
    				""
    			]
    		 },
    		 "Uploading...",
    		 ""
    		 ]
    		},
    	   ""
    	 ]
    	}
    },
    {
    	"elmType": "a",
        "attributes": {
    		"target": "_blank",
    		"href": {
    		  "operator": "+",
                "operands": [
                    "/sites/TW/Reviews/Reviews/Forms/EditForm.aspx?ID=",
                    "[$CID]"
                ]
    		}
    	},
    	"txtContent": {
    		"operator":"?",
    		"operands": [
    		{
    			"operator":"!=",
    			"operands":[
    				"[$New]",
    				""
    			]
    		},
    		{
    			"operator":"?",
    			"operands": [
    				{
    					"operator":"!=",
    					"operands":[
    						"[$CID]",
    						""
    					]
    				},
    				"Edit Review",
    				""
    				
    			]
    		},
    		""
    		]
    	}
    }
    ]
     }
    

    Here is the result of my test:

    User's image


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.