(Sharepoint JSON) Is it possible to change icons for a sharepoint list column based on checkboxes? - json

I have a list where I am trying to keep track of new parts for our company, and I want to set a progress bar to track how each item is progressing as it is introduced to the company. However, my boss wants to use checkboxes to mark certain stages as complete, so I was wondering if there is a way to set the JSON format script to select the correct progress bar icon depending on which or how many checkboxes are filled in. there are four checkboxes with the following names: CompareDrawingstoBOM, NewPartisScheduled, MaterialSecuredinNPL, ProgrammingComplete. I'm not really familiar with JSON at all so any help with this would be appreciated.

This is the basic JSON introduction that you could reference:
Site template JSON schema
Use column formatting to customize SharePoint
Try using below JSON code on your choice field:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "=join(#currentField, '\n')"
}
How join() works:
join() takes 2 operands. The first is an array (multi-select person or choice field) and the second is the separating string.
Returns a string concatenation of the array values separated by the separating string.
Example for multi-select choice field:
"txtContent": "=join(#currentField, ', ')" --> This will result in Apple, Orange, Cherry (depending on the selected values)
Example for multi-select person field:
"txtContent": "=join(#currentField.title, '|')" --> This will result in Chris Kent|Vesa Juvonen|Jeff Teper (depending on the selected persons names).

Related

How to allow check box to work in SharePoint without being in 'edit in grid view'?

I have a tracking sheet that I manage and I would like the ability to make the check box, which represents that a job has been completed, to be able to be checked (Yes/No Check box) without having to enter 'Edit in grid view'. Is this possible on the back end of SharePoint or through json?
I've looked at the settings in the SharePoint list and the column properties. Quick Edit is activated but it isn't doing what I hoped.
Based on your description, I understand that you want to fill in the checkbox column, but not in the "Edit in grid view".
If you want to edit items in the SharePoint list, you could through "Edit in grid view", "Edit item properties" and flows.
You could edit items by using " Update item" action when a job has been completed.
Yes. It is possible to edit the Yes/No column in SharePoint list view without using grid view.
You have to apply JSON column formatting for your Yes/No column. Use JSON like:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"inlineEditField": "[$Completed]",
"txtContent": "=if([$Completed], 'Yes', 'No')"
}
Where [$Completed] is the internal name of your column.
Output: When you click on column cell, it will open column in edit mode:
Documentation:
SharePoint JSON column formatting
JSON formatting inlineEditField

How to break new line on Microsoft Sharepoint list column description?

Not sure if this is a good place to ask but I’m about an hour into editing a Sharepoint for the first time, have zero prior knowledge on creating/editing Sharepoints, and I’m stuck trying to figure out how to wrap text to a new line in the description field of a particular column on my list.
We need the submitters to stop at a certain point and not touch the remaining fields, and the only way I can figure out how to do that is by adding a column description that tells them to stop. I want the description of that column to read as:
————-—STOP ————-—
Submitters stop here. Do not use the fields below, unless attaching images/files. The remaining fields are for macro champ use only.
———————————————-
Instead of :
————-—STOP ————-—Submitters stop here. Do not use the fields below, unless attaching images/files. The remaining fields are for macro champ use only.———————————————-
Do I need to use JSON to achieve this? If so..what is the code I would need to use?
Also open to alternative solutions to create a line/stop/hide fields from them or something.
——————
ETA - photo of what my column formatting box looks like.
——————
ETA for further clarification -
The column in particular that I am trying to add the “stop” message to is actually named “Attachments included?” And has ‘yes’ or ‘no’ radio choice buttons. Then the description underneath that column says “submitters stop here, unless attaching images/files below.” This column, and it’s description, are hidden from the list overview and only visible when submitting a +New item.
The reason for doing this is because we have a handful of fields towards the end of the +New item submission form that we don’t want submitters to touch, as they are for the help desk agents to fill out only.
I don’t see any other way to add a stop/line or hide certain fields from the submitters (while still leaving them visible to the help desk team), so just trying to make this “stop” description look a little neater.
Format the column as shown below:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": " ————-—STOP ————-— \n\n Submitters stop here. Do not use the fields below, unless attaching images/files. The remaining fields are for macro champ use only. \n\n ———————————————",
"style": {
"width": "100%",
"font-weight": "bold"
}
}
Update:

SharePoint Online JSON Column Formatting, if colum text is empty

I'm a big beginner with Json. Literally less than an hours experience.
I have a microsoft form that poulates a list within a SharePoint site, via a flow. I want to format a few of the colums so that if they have been left empty within the form, the text displayed will be 'N/A'.
Before anyone suggests it, I have tried setting the colums default value, but as the flow populates each row with whatever is in the microsoft form, it overwrites the default value with empty string.
Could there be another way to do this? An if statement within the flow maybe? Any help appreciated.
You could try the below code in JSON formatting:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "=if(#currentField=='','N/A',#currentField)"
}
Test result:

retrieving object properties from angularjs factory

I am completely stumped on this one. Everything's working fine (or fine enough for now) and all I need is to get the data back out of the factory in a non-json format. I've got a semi-working plunker with all the details.
Basically, the first page (under the Ctrl controller) is where a user can check a bunch of boxes. There's also an ng-switch between sets of options (the real things are much, much larger lists than these), so the checkboxFactory maintains the user's choices. When the user goes to the next page (or "next page" in the plunker because faking it), they can see what they chose. Those choices will then get wrapped up in a json post back to the server. I need to show the user-friendly name, but also have the id# of the choice, for the server.
If I put value="{{item.name}}" in the original checkbox ng-repeat, everything is fine. Except for the fact that then I have a factory of names, and not the server-required ids. Doing a second array in the factory (one for selected names, one for the corresponding selected ids) seems like overkill, when theoretically I could just add each selection as an object, and extract the properties as needed on the second page.
In reality, it's not working. Here's what I get if I echo the factory, after selections are made:
[ "{\"id\":1,\"name\":\"Firstplace\"}", "{\"id\":2,\"name\":\"Second place\"}" ]
...and I'm not sure, but those backslashes seem to be turning every selection into strings, because there are quotes just inside the square brackets. I've tried editing line 54 in the script, but I get errors. It doesn't like this:
if (checked && index == -1) {
if (setup) elem.prop('checked', false);
else scope.list.push({
id:"scope.value.id",
name:"scope.value.name"
});
On the html side, it doesn't like any of the variations I've tried in the ng-repeat, either. It seems like the source of all nightmares is that pushing is creating deformed json. I've tried all of these the second page/output:
{{item}}
{{item.name}}
{{item.item.name}}
The only one that works is {{item}} and unsurprisingly it's pretty ugly. Has anyone run into this before, and have any hints on how to fix this? Many thanks in advance.
using # will turn your object into a string, you should just use a reference to your item object instead and use =.
Change {{item}} to just item as a reference:
<input type="checkbox" name="group1" value="item" ng-model="isChecked" checkbox-list='checkedCity' />
In directive use =:
scope: {
list: '=checkboxList',
value: '='
},
see updated plunker

SSRS- charts colour coding

I have SSRS solution for SQL 2005 and 2008.
I am showing output in the form of chart- column chart with each column representing different database.
Is there a way to display each column in different color?
Regards
Manjot
You can use a formula to set the colour of each column, but that would work best if you knew what the individual series values ('databases'?) were going to be.
Right-click on your chart and bring up its properties. Now switch to the Data tab and select the first item in the Values list. Click the Edit... button to show the properties for the values (the columns) in your chart. Over on the Appearance tab there's a Series Style... button which takes you to another dialog.
On this new Style Properties dialog, switch to the Fill tab. That's where you set the colour for each of your columns. This can be a formula, so you might make it something like:
=Switch(
Fields!Database.Value = "master", "Blue",
Fields!Database.Value = "msdb", "Red",
"Green")
If you don't know in advance which 'databases' are going to be represented on the chart, this method won't work very well. In that case you might be able to come up with a formula which hashes the database name and comes up with a colour to match. That sounds like an interesting challenge, so add to your question if you need help doing something like that.
Edit
I just got a hash-based-colour-scheme working. It's a pretty nasty piece of code, but it did manage to get me a unique colour for every (string valued) column. Perhaps someone can come up with a better algorithm and post it here. Here's mine:
="#" & left(Hex(Fields!Database.GetHashCode()), 6)
So that's getting the HashCode for the string (a numeric value) and converting it to hex, then taking the leftmost six characters and prepending it with a "#" sign. That gives us a string that looks like a colour value (eg #AB12F0).