I am new to JSON and working on formatting a calendar within Microsoft Lists. I hope what I'm asking is an easy fix!
Essentially, the goal is to highlight on the calendar when a meeting contains the word "Nick" even though the meetings have different names. (ex. Nick: Review, Nick: Email, Nick: FYI)
My code (generated by Microsoft) is below.
{
"$schema": "//link removed",
"additionalEventClass": {
"operator": ":",
"operands": [
{
"operator": "==",
"operands": [
"[$Title]",
"Nick: Review"
]
},
"=if(#isSelected == true, 'sp-css-color-WhiteFont sp-css-backgroundColor-BgBlue' , 'sp-css-backgroundColor-BgCornflowerBlue sp-css-color-CornflowerBlueFont')",
"=if(#isSelected == true, 'sp-css-color-WhiteFont sp-css-backgroundColor-BgGray' , 'sp-css-backgroundColor-BgLightGray sp-css-color-LightGrayFont')"
]
}
}
I have been googling for contains functions or something using an asterisk similar to what I've used in other languages, but I'm unclear on how to integrate.
Related
I am trying to conditional format my sharepoint list so that I highlight files that has been published, ie. version does not contain "0."
I could not find out to use wildcard, so the below code with "0." was replaced with "0.*" did not work.
Can I change the operator from "!=" to something else that means contains or not contains?
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
"additionalRowClass": {
"operator": ":",
"operands": [
{
"operator": "!=",
"operands": [
"[$_UIVersionString]",
"0."
]
},
"sp-css-backgroundColor-BgMintGreen sp-field-fontSizeSmall sp-css-color-MintGreenFont",
""
]
}
}
Try using this JSON:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
"additionalRowClass": "=if(indexOf([$_UIVersionString], '0.') >= 0, '', 'sp-css-backgroundColor-BgMintGreen sp-field-fontSizeSmall sp-css-color-MintGreenFont')"
}
Documentation: SharePoint JSON formatting-syntax-reference
Problem: I want to search the description for "Vacation" in a string that reads "Name (Vacation)". there are many different Names, Name 1, Name 2, etc. the word "Vacation" is constant, I want to create 1 condition that formats all variations of Vacation.
I have played around with the operator changing "operator": "==", with no luck. Example "in", "$in", etc.
Is there an easy solution that I am missing?
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/calendar-formatting.schema.json",
"additionalEventClass": {
"operator": ":",
"operands": [
{
"operator": "==",
"operands": [
"[$Title_x0020_Category]",
"Name (Vacation)"
]
},
"=if(#isSelected == true, 'sp-css-color-WhiteFont sp-css-backgroundColor-BgGreen' , 'sp-css-backgroundColor-BgMintGreen sp-css-color-MintGreenFont')",
""
]
}
}
I would like to ask for some help with the conversion of a nested json into pandas df.
I have read the quite brilliant input from a couple of year past, but that is outdated now. :(
Flatten double nested JSON
So here is a sample of my input data (mind that classes might contain up to 10 class name and confidence pairs):
[
{
"classifier_id": "my_classifier_id",
"url": "https://api.eu-de.natural-language-classifier...",
"text": "for sales? aligning obsolete incentive\u00a0 system to what is the standard today: 100% reference salary, 100% of ref sal if you hit 100% of your quota",
"top_class": "conditions",
"classes": [
{
"class_name": "conditions",
"confidence": 0.9074866214536228
},
{
"class_name": "temperature",
"confidence": 0.09251337854637723
}
]
},
{
"classifier_id": "my_classifier_id",
"url": "https://api.eu-de.natural-language-classifier...",
"text": "Complete integration of incentives.\u00a0 People act inline with how they are compensated as the general rule. \u00a0 If we get that right then this model can genuinely change the face of IBM to the client.",
"top_class": "conditions",
"classes": [
{
"class_name": "conditions",
"confidence": 0.9683663322166756
},
{
"class_name": "temperature",
"confidence": 0.0316336677833244
}
]
},
{
"classifier_id": "my_classifier_id",
"url": "https://api.eu-de.natural-language-classifier.watson...",
"text": "Enablement, operational support on the most basic things",
"top_class": "temperature",
"classes": [
{
"class_name": "temperature",
"confidence": 0.8174158442711534
},
{
"class_name": "conditions",
"confidence": 0.1825841557288465
}
]
}
]
What I have tried thus far in python:
data_df = pd.read_json(r'C:\Users\...\Documents\Python NLP\WATSON NLC\OUTPUT JSON\nlc_data_full.json')
When using this the classes still remain in a json like form:
[{'class_name': 'conditions', 'confidence': 0.907486621453622}, {'class_name': 'temperature', 'confidence': 0.092513378546377}]
[{'class_name': 'conditions', 'confidence': 0.9683663322166751}, {'class_name': 'temperature', 'confidence': 0.031633667783324}]
[{'class_name': 'temperature', 'confidence': 0.8174158442711531}, {'class_name': 'conditions', 'confidence': 0.182584155728846}]
I would love to get a format that can be worked on in excel. Thank you for looking into this.
Well I think I managed to figure out what everyone already knew anyways. LOL
So the magic is in the pd.json_normalize function. With the parameters it takes it basically is able to open multinested json files with relative ease.
Also the pandas site has been a good friend as always: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.json_normalize.html
I am calling my dataset: nlc_data = [ .......
Here is a super lightweight solution for cases that do not have such intricate nesting: normie_2 = pd.json_normalize(nlc_data, max_level=0)
This one works for multi nested json files:
result = pd.json_normalize(nlc_data, 'classes', ['text', 'top_class'])
Well I guess I got a lot smarter today. Bare with me ... I just might have another awesome questions tomorrow.
Bye, Levi
I am very new to all this. I dont really know what most of these codes are, but with a little searching and trial an error I achieve my goals by changing bits and pieces. My current goal is to format a fields background color depending on the value of that field.
I found a very nice post on the subject. The problem is I need to combine a couple examples and I am having a problem. Here is the post.
https://learn.microsoft.com/en-us/sharepoint/dev/declarative-customization/column-formatting.
I have a date field called "Proposal Due Date". When the date is past, I want the BG one color. When the date is approaching (5 working days out) I want the BG another.
Below are the 2 examples I found and edited. I can only do one or the other. I need them both in the same format column box.
I can do the first part easy. It makes the BG a redish color if the date is past... Except it included todays date.
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "div",
"debugMode": true,
"txtContent": "#currentField",
"style": {
"background-color": "=if([$Proposal_x0020_Due_x0020_Date] < #now, '#FAAAAA', '')"
}
}
The second part is a bit tricky for me. I dont know how to make this check 5 working days ahead instead of just 5 days. I also dont know how to prevent it from including days past.
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "div",
"txtContent": "#currentField",
"style": {
"background-color": {
"operator": "?",
"operands": [
{
"operator": "<=",
"operands": [
"[$Proposal_x0020_Due_x0020_Date]",
{
"operator": "+",
"operands": [
"#now",
432000000
]
}
]
},
"#FCFC00",
""
]
}
}
}
I was looking for a way if JSON Script can look other column and format other column. base on the value of the other column.
Is there an alternate way to use "#currentfield"?
Thanks
Check the Apply formatting based on date ranges demo.
{
"elmType": "div",
"txtContent": "#currentField",
"style": {
"color": {
"operator": "?",
"operands": [
{
"operator": "<=",
"operands": [
"[$DueDate]",
"#now"
]
},
"#ff0000",
""
]
}
}
}
The MS Docs link #Lee_MSFT provided has some decent examples on formatting. In addition to the notes on internal/field names in the discussion on date ranges, the doc includes instructions for cross-referencing other columns (https://learn.microsoft.com/en-us/sharepoint/dev/declarative-customization/column-formatting#fieldname). Essentially, if you want to reference/use data from column A to format column B, you will need to use the "internal name" of column A in the JSON formatting on column B. A column name may be (and often is) different than the "display name" of the column. For example, we have a basic list for tracking some team members:
"Alias/Logon" (SLOT); internal name: Title
"First Name" (SLOT); internal name: FirstName
"Last Name" (SLOT); internal name: LastName
"Current Contracts" (SLOT); internal name: CurrentContracts
We want "Current Contracts" to be a URL link that uses the "Alias/Logon" value and we also want to display an icon. In fact, this column doesn't even require content as it will show an actual icon and the word "Contracts" for all users. Obviously, if you reference a column that is not mandatory, you should do some data validation to ensure you aren't creating bad URLs, etc.
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "a",
"attributes": {
"target": "_blank",
"iconName": "BulletedList",
"class": "sp-field-quickActions",
"href": {
"operator": "+",
"operands": [
"https://mycompany.sharepoint.com/teams/coolpeople/contracts/",
"[$Title]"
]
}
},
"txtContent": "Contracts"
}
Note: just do a search for "SharePoint JSON column formatting" to find a plethora of examples, including the repo on GitHub (https://github.com/SharePoint/sp-dev-list-formatting).