In my list, I am referring to a hyperlink column on whether or not to show a field in a different column. My hyperlink field name is "Link to Site", so the internal name is "Link_x0020_to_x0020_Site".
I cannot get the logic to show/hide appropriately based on whether the Url in the hyperlink is empty or not - here is the beginning of my json:
{
"$schema": "https: //developer.microsoft.com/en-us/json-schemas/sp/column-formatting.schema.json",
"elmType": "span",
"style": {
"color": "#0078d7",
"display": "=if([$Link_x0020_to_x0020_Site]=='', '', 'none'"
},
If you want to show the span element if hyperlink column is empty, use in this format:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "span",
"style": {
"color": "#0078d7",
"display": "=if([$Link_x0020_to_x0020_Site] == '', 'inherit', 'none')"
},
If you want to hide the span element if hyperlink column is empty, use in this format:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "span",
"style": {
"color": "#0078d7",
"display": "=if([$Link_x0020_to_x0020_Site] == '', 'none', 'inherit')"
},
You can also try using block if inherit is not working for you.
Related
I'm new to JSONPath and want to write a JSONPath-syntax that retrieves the property value only if a certain condition is met. The value I'm after is not part of an array, but I've managed to make filtering work in the following JSONPath tool: https://www.site24x7.com/tools/json-path-evaluator.html
Given the following JSON, I only want to extract the value of column2.dimValue if column2.attributeId equals B0:
{
"batchId": 279,
"companyId": "40",
"period": 202208,
"taxCode": "1",
"taxSystem": "",
"transactionDate": "2022-08-05T00:00:00.000",
"transactionNumber": 222006089,
"transactionType": "IF",
"year": 2022,
"accountingInformation": {
"account": "4010",
"column1": {
"attributeId": "H9",
"dimValue": "76"
},
"column2": {
"attributeId": "B0",
"dimValue": "2170103"
},
"column3": {
"attributeId": "",
"dimValue": ""
},
"column4": {
"attributeId": "BF",
"dimValue": "217010330"
},
"column5": {
"attributeId": "10",
"dimValue": "3101"
},
"column6": {
"attributeId": "06",
"dimValue": ""
},
"column7": {
"attributeId": "19",
"dimValue": "K"
}
},
"categories": {
"cat1": "H9",
"cat2": "B0",
"cat3": "",
"cat4": "BF",
"cat5": "10",
"cat6": "06",
"cat7": "19",
"dim1": "76",
"dim2": "2170103",
"dim3": "",
"dim4": "217010330",
"dim5": "3101",
"dim6": "",
"dim7": "K"
},
"amounts": {
"amount": 48.24,
"amount3": 0.0,
"amount4": 0.0,
"currencyAmount": 48.24,
"currencyCode": "NOK",
"debitCreditFlag": 1
},
"invoice": {
"customerOrSupplierId": "58118",
"description": "",
"externalArchiveReference": "",
"externalReference": "2170103",
"invoiceNumber": "220238522",
"ledgerType": "P"
},
"additionalInformation": {
"number": 0,
"orderLineNumber": 0,
"orderNumber": 0,
"sequenceNumber": 1,
"status": "",
"value": 0.0,
"valueDate": "2022-08-05T00:00:00.000"
},
"lastUpdated": {
"updatedAt": "2022-09-05T10:59:11.633",
"updatedBy": "HELVES"
}
}
I've used this JSONPath-syntax:
$['accountingInformation']['column2'][?(#.attributeId=='B0')].dimValue
This gives the following result:
[
"2170103"
]
I'm using this result in Azure Data Factory mapping, and it seems that it doesn't work as the result is an array.
Can anyone help me with the syntax to it only returns the actual value? Is that even possible?
I repro'd the same and below is the approach.
Sample Json file is taken as in below image as a source in lookup activity.
If activity is taken to filter the value of column2 with attributeId='B0'. Expression is given as below
#equals(activity('Lookup1').output.value[0].accountingInformation.column2.attributeId ,'B0')
In true case of IF activity, Set Variable is added. New Variable with string type is taken and it is set using below expression.
#activity('Lookup1').output.value[0].accountingInformation.column2.dimvalue
Then Copy activity is added next to IF activity sequentially. In source dummy dataset is taken. +New is click in additional columns
Name: col1
Value: #variables('v2')
In Mapping, Import schemas is clicked. All other columns except the additional column that is added in source are deleted.
Pipeline is debugged and data is copied to sink without error.
By default, the values in a Lookup column display as links.
Clicking on these links takes you to the relevant item in the lookup list.
When setting the column to Allow multiple values, each value is displayed on a separate line.
To make the values appear on one line, I have applied this column formatting:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "=join(#currentField.lookupValue, ', ')"
}
This results in the desired behavior of the values being on one line, separated by commas, eg:
Value1, Value2, Value3
However, the values are just plain text, ie the links have been removed.
How can I retain the links for each of the values, whilst still displaying them on one line.
Edit 1:
It seems that Lookup columns have two properties available via column formatting:
.lookupValue
.lookupId
When you click on a link in a Lookup column, it goes to a URL with this structure:
https://tenant-name.sharepoint.com/sites/site-name/Lists/Some%20List/DispForm.aspx?ID=n
Where the n at the end of the URL is the lookupId.
So one possible solution would be to:
use .lookupId to get the ID of the item in the lookup list
for each value in the lookup column, construct the URL and concatenate the .lookupId value to the end
Using this post an inspiration, the following code almost works, but the ID value in each of the links is output as the same (and is also incorrect):
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"children": [
{
"elmType": "a",
"style": {
"display": "block",
"width": "100%"
},
"txtContent": "=join(#currentField.lookupValue, ', ')",
"attributes": {
"target": "_blank",
"href": "='https://tenant-name.sharepoint.com/sites/site-name/Lists/Some%20List/DispForm.aspx?ID=' + [$ID]"
}
}
]
}
Edit 2:
Based on this answer, which references this blog post, the following achieves the desired behaviour using forEach, but it adds a trailing comma on the end of all last values in the column:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "div",
"children": [
{
"forEach": "lookupIterator in #currentField",
"elmType": "a",
"txtContent": "=[$lookupIterator.lookupValue] + ', '",
"attributes": {
"target": "_blank",
"href": "='https://tenant-name.sharepoint.com/sites/site-name/Lists/Some%20List/DispForm.aspx?ID=' + [$lookupIterator.lookupId]"
}
}
]
}
Below is another way to do it using operator and operands but it still shows the undesired trailing comma:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "div",
"children": [
{
"forEach": "lookupIterator in #currentField",
"elmType": "a",
"txtContent": {
"operator": "+",
"operands": [
"[$lookupIterator.lookupValue]", ", "
]
},
"attributes": {
"target": "_blank",
"href": "='https://tenant-name.sharepoint.com/sites/site-name/Lists/Some%20List/DispForm.aspx?ID=' + [$lookupIterator.lookupId]"
}
}
]
}
I don't know if it's possible to somehow define different concatenation on the last item in the loop, with something like:
"=if(loopIndex('lookupIterator') == length(#currentField - 1), 'DON'T ADD COMMA', 'DO ADD COMMA')"
This seems to work:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "div",
"children": [
{
"forEach": "lookupIterator in #currentField",
"elmType": "a",
"txtContent": "=if(loopIndex('lookupIterator') == length(#currentField) - 1, [$lookupIterator.lookupValue], [$lookupIterator.lookupValue] + ', ')",
"attributes": {
"target": "_blank",
"href": "='https://tenant-name.sharepoint.com/sites/site-name/Lists/Some%20List/DispForm.aspx?ID=' + [$lookupIterator.lookupId]"
}
}
]
}
It uses forEach, an if() statement, loopIndex and length() to concatenate values conditionally, i.e:
if it's the last item in the loop, don't add the separating comma
if it's not the last item in the loop, do add the separating comma
To be honest, i'm surprised the conditional structure worked in there, and the referenced column values as well.
Bonus
It seems you can also add a style property under txtContent which uses the same conditional logic, just to make the gap between values larger than the default 1 space character, i.e:
"style": {
"padding-right": "=if(loopIndex('lookupIterator') == length(#currentField) - 1, '0px', '5px'"
},
Im trying to use a MultiSelectFormField to create a drop down list with multiple choices.The datasource for the MultiSelectFormField is required in the below format,
dataSource:[
{
"display": "Running",
"value": "Running",
},
{
"display": "Climbing",
"value": "Climbing",
},
{
"display": "Walking",
"value": "Walking",
},
],
but what I have is a list of type string containing the value sthat should be displayed in the drop down.My question is how can I convert
list<String> dropDownValues=["Running","Climbing","Walking"]
to the format required
Please use the map operator
final dropDownValues=["Running","Climbing","Walking"];
final data = dropDownValues.map((el) => {"display": el,"value" el,}).toList();
I am trying to develope a simple messagaging extension app for Microsoft Teams. With the use of Task Modules I can load a simple Adative Card. Works as designed. The only problem I have with it, is that my Adaptive Card has a color issue withing Microsoft Teams in Dark Mode.
Take a look at the image below. 1 shows a very simple Adaptive Card designed via https://adaptivecards.io/designer/ (preview mode). 2 the very same Adaptive Card but now an actual snippet from Microsoft Teams. As you can see the card below has some color issues which makes the input hard to see.
Here is the code I've used:
public async handleTeamsMessagingExtensionFetchTask(
context: TurnContext,
action: any
): Promise<any> {
const adaptiveCard = CardFactory.adaptiveCard({
"type": "AdaptiveCard",
"body": [
{
"type": "TextBlock",
"size": "Medium",
"weight": "Bolder",
"text": "${title}"
},
{
"type": "Input.Text",
"placeholder": "Placeholder text"
}
],
"actions": [
{
"type": "Action.Submit",
"title": "Submit"
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.3"
});
return {
task: {
type: 'continue',
value: {
card: adaptiveCard,
height: 535,
title: '${title}',
url: null,
width: 500
}
}
};
}
There's not much that can be done about the input box itself in this case, but maybe try changing the colour of the label above it, something like this (I've changed some of your property names as well, as they were invalid case - things like "medium" instead of "Medium":
"size": "medium",
"weight": "bolder",
"text": "${title}",
"color": "good"
Color allows the following values:
"default"
"dark"
"light"
"accent"
"good"
"warning"
"attention"
If you nest your Text input into a Container, you are able change the Container's style to provide a coloured background upon which the Text input sits.
It's not necessarily right for your use case, but it could be a workaround of interest
Container Style colour options
{
"type": "Container",
"style": "emphasis",
"bleed": true,
"items": [
{
"type": "TextBlock",
"text": "Request New Ticket",
"wrap": true,
"fontType": "Default",
"style": "heading",
"size": "Large",
"color": "Good",
"weight": "Bolder",
"horizontalAlignment": "Center"
}
]
}
I am trying to make a call to a Power Automate Instant Flow from a formatted column. I'm taking my inspiration from this article - https://www.inspiribytes.com/power-automate/deploying-a-single-flow-to-multiple-sharepoint-libraries-lists/
I set up the column with the json:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "button",
"customRowAction": {
"action": "executeFlow",
"actionParams": "{\"id\": \"0aa2105b-755e-4017-aac8-b1b823ea96d1\"}"
},
"attributes": {
"class": "ms-fontColor-themePrimary ms-fontColor-themeDarker--hover"
},
"style": {
"border": "none",
"background-color": "transparent",
"cursor": "pointer"
},
"children": [
{
"elmType": "span",
"attributes": {
"iconName": "Flow"
},
"style": {
"padding-right": "6px"
}
},
{
"elmType": "span",
"txtContent": "Start Approval"
}
]
}
I created my Instant FLow, and noted the ID in the URL and changed the JSON in the formatted column to match.
When I click the button, I see a message that says "Setting Up" - clicking it, it just says "Waiting"
When I review the Developer Console, I see the following message:
POST https://prod-176.westus.logic.azure.com/workflows/b294beca8451414787bae052f8be6181/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=8s7N19sj-J3iZjMy90RvM7xKkcvujUkQCBPWxB6rZcc 400
So I'm getting a Bad Request, but I cannot figure out why. There doesn't appear to be any other parameters that I should be setting other than the ID of the workflow.
In my test, I cannot reproduce your problem.
There is no problem with your JSON code. I suggest you provide the screenshots of your flow, which will help us solve the problem better.