Share via

How do I use multple IF statements using JSON Code

Anonymous
2021-05-27T16:24:58+00:00

I have been working for sometime on this JSON but am stuck.
Here is the code and it's not working as I hoped it would.

I have two fields that I am evaluating and based on what those two fields are set to determine if I should show a button or not within a SharePoint field using JSON.

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
 
"elmType": "button",
"txtContent": "Launch DI Exit",
"customRowAction": {
"action": "executeFlow",
"actionParams": "{"id": "86***78-e4*c-4*6d-9**7-08**9f6***"}"
  },
  "style": {
    "background-color": "#0080ff",
    "color": "white",
    "border-radius": "0 15px",
    "visibility": "=if(([$DIExitApprovalStatus] == 'Pending'&& [$WorkflowRequired]=='DI Exit','visible','hidden')"
  }
 
"elmType": "button",
"txtContent": "Launch OA Exit",
"customRowAction": {
"action": "executeFlow",
"actionParams": "{"id": "e78***07-2**d-4**e-9**3-9aa4fc67***"}"
  },
  "style": {
    "background-color": "#008082",
    "color": "white",
"border-radius": "0 15px",
"visibility": "=if(([$OAExitApprovalStatus] == 'Pending'&& [$WorkflowRequired]=='OA Exit','visible','hidden')"
  }
 
"elmType": "button",
"txtContent": "Launch CD_CV Exit",
"customRowAction": {
"action": "executeFlow",
"actionParams": "{"id": "52**e98-e**b-4**7-a**1-d5e8e72***"}"
  },
  "style": {
    "background-color": "#008082",
    "color": "white",
    "border-radius": "0 15px",
"visibility": "=if(([$CD_CVExitApprovalStatus] == 'Pending'&& [$WorkflowRequired]=='CD_CV Exit','visible','hidden')"

  }
} Thanks for your help!
Been searching all over the internet and can't find anything regarding this.

Microsoft 365 and Office | SharePoint | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2021-05-27T23:07:46+00:00

Dear Christopher,

After my test, you can use the following code to see the result.

{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json","elmType": "span","children": [{"elmType": "button","txtContent": "Launch Flow for DI Exit","customRowAction": {"action": "executeFlow","actionParams": "{"id": "b6**80-f**2-4**d-a**1-0524a6***"}"},"style": {"background-color": "#0080ff","color": "white","border-radius": "0 15px","visibility": "=if(([$DIExitApprovalStatus] == 'Pending')&&([$WorkflowRequired]=='Flow for DI Exit'),'visible','hidden')"}},{"elmType": "button","txtContent": "Launch Flow for OA Exit","customRowAction": {"action": "executeFlow","actionParams": "{"id": "20***dad-a**a-4**4-a**4-d7b0a4***"}"},"style": {"background-color": "#008082","color": "white","border-radius": "0 15px","visibility": "=if(([$OAExitApprovalStatus] == 'Pending')&&([$WorkflowRequired]=='Flow for OA Exit'),'visible','hidden')"}},{"elmType": "button","txtContent": "Launch Flow for CD_CV Exit","customRowAction": {"action": "executeFlow","actionParams": "{"id": "4b***c13-0**0-4**2-9**9-748865***"}"},"style": {"background-color": "#008082","color": "white","border-radius": "0 15px","visibility": "=if(([$CD_CVExitApprovalStatus] == 'Pending')&&([$WorkflowRequired]=='Flow for CD_CV Exit'),'visible','hidden')"}}]} I create the list as follows.

Image

Best Regards,

Cliff

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Anonymous
    2021-05-28T14:24:42+00:00

    Outstanding!
    I will study the difference in what I had and what you gave me.
    Learning JSON is awesome!

    So, appreciate your assistance and providing me a learning opportunity!

    Best Regards,

    Chris

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2021-05-27T20:24:57+00:00

    Hi Cliff,
    I really appreciate your time.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2021-05-27T20:14:49+00:00

    Dear Christopher,

    I need some time to do a test and I'll update here as soon as possible.

    Best Regards,

    Cliff

    Was this answer helpful?

    0 comments No comments