Skip to content

Instantly share code, notes, and snippets.

@bcameron1231
Created March 16, 2021 15:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bcameron1231/7be82cd0ffb1b4e9170ea291cbebd4a3 to your computer and use it in GitHub Desktop.
Save bcameron1231/7be82cd0ffb1b4e9170ea291cbebd4a3 to your computer and use it in GitHub Desktop.
fetch("https://Test.sharepoint.com/sites/JSON-Formatting/_api/web/lists/getbytitle('Demo')/contentTypes('0x0100F566899D669FFB4D9CA9135D63C98EAB001D365D0D20AF3E478A1E321ACB5C901F')", {
"headers": {
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
"x-requestdigest": "0x4ABCD6C5885557D4C225950F1237F8A340BDD7016B18DD0F95937199252929CF8268CD5C17EB21EEEF09801D16DA9160E0D9D609EEAB4DFD52E6928665BA2436,16 Mar 2021 15:28:38 -0000"
},
"body": "{\"__metadata\":{\"type\":\"SP.ContentType\"},\"ClientFormCustomFormatter\":\"{\\\"headerJSONFormatter\\\":{\\\"$schema\\\":\\\"https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json\\\",\\\"debugMode\\\":false,\\\"elmType\\\":\\\"div\\\",\\\"attributes\\\":{\\\"class\\\":\\\"ms-borderColor-neutralTertiary ms-fontSize-20\\\"},\\\"style\\\":{\\\"font-family\\\":\\\"Segoe UI\\\",\\\"width\\\":\\\"80%\\\",\\\"border-top-width\\\":\\\"5px\\\",\\\"border-bottom-width\\\":\\\"1px\\\",\\\"border-left-width\\\":\\\"0px\\\",\\\"border-right-width\\\":\\\"0px\\\",\\\"border-style\\\":\\\"solid\\\",\\\"margin-bottom\\\":\\\"16px\\\",\\\"display\\\":\\\"=if([$Status]=='','none',''\\\"},\\\"children\\\":[{\\\"elmType\\\":\\\"div\\\",\\\"attributes\\\":{\\\"class\\\":\\\"=if([$Status]=='','ms-bgColor-white',if([$Status]== 'Available', 'ms-bgColor-green', if([$Status]== 'In use', 'ms-bgColor-blue', if([$Status]== 'Reserved', 'ms-bgColor-yellow', if([$Status] == 'In repair', 'ms-bgColor-red', 'ms-bgColor-red')))))\\\"},\\\"style\\\":{\\\"width\\\":\\\"20px\\\",\\\"height\\\":\\\"180px\\\",\\\"display\\\":\\\"flex\\\",\\\"flex-direction\\\":\\\"column\\\",\\\"align-items\\\":\\\"center\\\"}},{\\\"elmType\\\":\\\"div\\\",\\\"attributes\\\":{\\\"class\\\":\\\"ms-bgColor-themePrimary ms-fontColor-white\\\"},\\\"style\\\":{\\\"margin\\\":\\\"5px\\\",\\\"width\\\":\\\"100%\\\",\\\"height\\\":\\\"160px\\\",\\\"border\\\":\\\"5px ridge\\\",\\\"padding\\\":\\\"6px\\\",\\\"display\\\":\\\"flex\\\",\\\"flex-direction\\\":\\\"column\\\",\\\"align-items\\\":\\\"center\\\"},\\\"children\\\":[{\\\"elmType\\\":\\\"div\\\",\\\"txtContent\\\":\\\"='[$Model]' + ' (' + '[$AssetType]' + ')'\\\",\\\"attributes\\\":{\\\"class\\\":\\\"ms-fontWeight-bold\\\"}},{\\\"elmType\\\":\\\"div\\\",\\\"txtContent\\\":\\\"[$Title]\\\",\\\"attributes\\\":{\\\"class\\\":\\\"ms-fontWeight-bold\\\"},\\\"style\\\":{\\\"text-decoration\\\":\\\"underline\\\"}},{\\\"elmType\\\":\\\"div\\\",\\\"txtContent\\\":\\\"=[$Manufacturer] + ' (' + [$SerialNumber] + ')'\\\"},{\\\"elmType\\\":\\\"div\\\",\\\"children\\\":[{\\\"elmType\\\":\\\"span\\\",\\\"style\\\":{\\\"padding-right\\\":\\\"8px\\\"},\\\"txtContent\\\":\\\"Email Manufacturer\\\"},{\\\"elmType\\\":\\\"a\\\",\\\"class\\\":\\\"sp-field-quickActions\\\",\\\"attributes\\\":{\\\"class\\\":\\\"ms-fontSize-20 ms-fontColor-white\\\",\\\"iconName\\\":\\\"Mail\\\",\\\"href\\\":\\\"='mailto:' + '' + '?subject='+ [$Model]+' - Order Number: '+[$OrderNumber]+' - Serial Number: '+ [$SerialNumber] + '&body=Hello, \\\\r\\\\n\\\\r\\\\n' + 'I have the following query regarding the order: '\\\"}}]},{\\\"elmType\\\":\\\"div\\\",\\\"children\\\":[{\\\"elmType\\\":\\\"span\\\",\\\"attributes\\\":{\\\"iconName\\\":\\\"Money\\\",\\\"class\\\":\\\"ms-fontWeight-regular\\\",\\\"title\\\":\\\"Money\\\"},\\\"style\\\":{\\\"flex\\\":\\\"none\\\",\\\"padding-top\\\":\\\"10px\\\",\\\"padding-right\\\":\\\"5px\\\",\\\"padding-left\\\":\\\"0px\\\",\\\"height\\\":\\\"10px\\\"}},{\\\"elmType\\\":\\\"span\\\",\\\"txtContent\\\":\\\"$\\\"},{\\\"elmType\\\":\\\"span\\\",\\\"txtContent\\\":\\\"[$PurchasePrice]\\\"}]},{\\\"elmType\\\":\\\"div\\\",\\\"style\\\":{\\\"justify-content\\\":\\\"center\\\",\\\"width\\\":\\\"100%\\\",\\\"height\\\":\\\"35px\\\"},\\\"attributes\\\":{\\\"class\\\":\\\"=if([$DueDate]=='','',if(Number(Date([$DueDate])) <= Number(@now),'ms-bgColor-white ms-fontColor-themePrimary',''))\\\"},\\\"children\\\":[{\\\"elmType\\\":\\\"div\\\",\\\"style\\\":{\\\"display\\\":\\\"flex\\\",\\\"flex-direction\\\":\\\"row\\\"},\\\"children\\\":[{\\\"elmType\\\":\\\"div\\\",\\\"style\\\":{\\\"width\\\":\\\"100%\\\",\\\"display\\\":\\\"flex\\\",\\\"flex-direction\\\":\\\"column\\\",\\\"align-items\\\":\\\"center\\\",\\\"margin\\\":\\\"0px\\\"},\\\"children\\\":[{\\\"attributes\\\":{\\\"class\\\":\\\"ms-fontSize-24\\\",\\\"iconName\\\":\\\"=if([$DueDate]=='','',if(Number(Date([$DueDate])) <= Number(@now),'Warning',''))\\\"},\\\"elmType\\\":\\\"div\\\",\\\"txtContent\\\":\\\"=if([$DueDate]=='','',if(Number(Date([$DueDate])) <= Number(@now),' Asset is Due!',''))\\\",\\\"style\\\":{\\\"margin-top\\\":\\\"5px\\\"}}]}]}]}]},{\\\"elmType\\\":\\\"img\\\",\\\"attributes\\\":{\\\"src\\\":\\\"[$DevicePhoto.serverRelativeUrl]\\\"},\\\"style\\\":{\\\"height\\\":\\\"180px\\\"}}]},\\\"footerJSONFormatter\\\":\\\"\\\",\\\"bodyJSONFormatter\\\":{\\\"sections\\\":[{\\\"displayname\\\":\\\"Information\\\",\\\"fields\\\":[\\\"Asset tag\\\",\\\"Manufacturer\\\",\\\"Model\\\",\\\"Asset type\\\"]},{\\\"displayname\\\":\\\"Details\\\",\\\"fields\\\":[\\\"Serial number\\\",\\\"Order #\\\",\\\"Color\\\",\\\"Purchase price\\\",\\\"Purchase date\\\"]},{\\\"displayname\\\":\\\"Ownership\\\",\\\"fields\\\":[\\\"Current owner\\\",\\\"Due date\\\",\\\"Previous owner\\\"]},{\\\"displayname\\\":\\\"Stattus\\\",\\\"fields\\\":[\\\"Status\\\",\\\"Condition notes\\\",\\\"Device Photo\\\"]}]}}\"}",
"method": "MERGE",
"mode": "cors",
"credentials": "include"
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment