What does the data json need to be to set a choice as selected on an Input.ChoiceSet?
Card Json
{
"type": "AdaptiveCard",
"body": [
{
"type": "Input.ChoiceSet",
"placeholder": "Placeholder text",
"choices": [
{
"title": "Choice 1",
"value": "1"
},
{
"title": "Choice 2",
"value": "2"
}
],
"style": "expanded",
"id": "sample"
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.0"
}
Sample Data Json
What should the structure of this be if I wanted to set the value of Choice 1 to selected?
{
// I've tried this:
"sample": {
"value": "1"
}
}
-----------------------------
{
// Also tried
"sample": "1"
}
I'm reading the Adaptive Card schema for Input.ChoiceSet and I see that the card json "value": property can be set in the card for default values, but I'm hoping there is a way to do this from the template json. Otherwise, I'll have to "inject" it into the card json before I build the card.
based on your sample there you have to do this:
[...]
"placeholder": "Placeholder text",
"value": 1,
"choices": [
{
"title": "Choice 1",
"value": "1"
},
[...]
To set the initial value, based on one of the values in your choices array. It only works if the corresponding value is exactly the same for one of the entries.
There is nothing like "selected: true" or similar if that's what you're asking for.
When using templating for that, you would have to have a selected property returned and set it as "value": {$root.selected}
Related
I know I am close on this, the error messages are getting nicer. Currently, I can call a similar call to update the seller's email no issue via Postman currently, working on updating the amount and associated objects. Something in my request format is off.
Is my breakdown section in the correct location? The amount_breakdown documentation looks like it is on same level as value and currency_code, so does it need to move into that section.
Here's my request JSON via Postman:
[
{
"op": "replace",
"path": "/purchase_units/#reference_id=='default'/amount",
"value": {
"currency_code": "CAD",
"value": "2",
"amount": {
"currency_code": "CAD",
"value": "2",
"breakdown": {
"item_total": {
"currency_code": "CAD",
"value": "2"
},
"tax_total": {
"value": "0",
"currency_code": "CAD"
}
}
},
"items": [
{
"name": "First Product Name",
"description": "Optional descriptive text..",
"unit_amount": {
"currency_code": "CAD",
"value": "2"
},
"tax": {
"value": "0",
"currency_code": "CAD"
},
"quantity": "1"
}
]
}
}
]
RESPONSE:
{
"name": "UNPROCESSABLE_ENTITY",
"details": [
{
"field": "/purchase_units/#reference_id=='default'/amount/breakdown/item_total",
"location": "body",
"issue": "ITEM_TOTAL_REQUIRED",
"description": "If item details are specified (items.unit_amount and items.quantity) corresponding amount.breakdown.item_total is required."
}
],
"message": "The requested action could not be performed, semantically incorrect, or failed business validation.",
"debug_id": "acecd3643c994",
"links": [
{
"href": "https://developer.paypal.com/docs/api/orders/v2/#error-ITEM_TOTAL_REQUIRED",
"rel": "information_link",
"method": "GET"
}
]
}
Thanks for any help!
Different variations of objects.
I can get the other PATCH operation working no issue but it is much simpler in object structure
There should be no amount key under the /amount path, and the items array does not belong at that /amount path either.
I am working with a specific API that returns a JSON that looks like the below sample.
I want to get both values that contain the #text and #attr but I get error messages in typescript when I try to get the values.
try using,
album[0]["#attr"]
album[0]["artist"]["#text"]
Hey for JSON you can use get details by its attribute name in it and it's the same for all-weather it starts with # or # it will be the same.
See below code to get the value of your specified key:
Sample JSON:
{
"weeklyalbumchart": {
"album": [
{
"artist": {
"mbid": "data",
"#text": "Flying Lotus"
},
"mbid": "data",
"url": "",
"name": "",
"#attr": {
"rank": "1"
},
"playcount": "21"
},
{
"artist": {
"mbid": "data",
"#text": "Flying Lotus"
},
"mbid": "data",
"url": "",
"name": "",
"#attr": {
"rank": "1"
},
"playcount": "21"
}
]
}
}
Read JSON:
#attr ===> json["weeklyalbumchart"]["album"][0]["#attr"]
#text ===> json["weeklyalbumchart"]["album"][0]["artist"]["#text"]
Hope this will help you to understand it.
I am developing Microsoft teams bot using ms bot framework. In that, i am using adaptive cards for displaying description and two buttons.
when user clicks the button, that time i need pass json data to backend. If I pass string data ("data": "ONE") on button action then I can able to read the arguments in backend and user clicked button text is coming in bot. Kindly see the code and output image below
{
"contentType": "application/vnd.microsoft.card.adaptive",
"content": {
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "TextBlock",
"text": "Hi, this is your Botzer personal assistant , how can I help you? Click Here ",
"weight": "bolder",
"isSubtle": false,
"wrap": true
}
],
"actions": [
{
"type": "Action.Submit",
"title": "ONE",
"data": "ONE"
},
{
"type": "Action.Submit",
"title": "TWO",
"data": "TWO"
}
]
}
}
But, when I send json data on button action ("data": { "id": "action2", "name": "two", "value": "TWO"}) that time i can read the data in backend. But, button text is not coming on the bot. Kindly see the code and output image below
"contentType": "application/vnd.microsoft.card.adaptive",
"content": {
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "TextBlock",
"text": "Choose the number",
"weight": "bolder",
"isSubtle": false,
"wrap": true
}
],
"actions": [
{
"type": "Action.Submit",
"title": "ONE",
"data": {
"id": "action1",
"name": "one",
"value": "ONE"}
},
{
"type": "Action.Submit",
"title": "TWO",
"data": {
"id": "action2",
"name": "two",
"value": "TWO"}
}
]
}
}
What you want is called a message back, which combines the functionality of string submit actions and object submit actions. Since you don't have any inputs in your Adaptive Card, you can replace it with a hero card and use a messageBack action directly. If you still want to use an Adaptive Card then you're in luck because Teams actually has special functionality that allows you to put a message back in an Adaptive Card. You can see how to do that in the "Adaptive Cards in Teams" section of the blog post Hessel linked to, or you can consult the documentation directly.
I would like to create a variable for a list of select options that can be re-used for multiple settings. example (variable state_list in the code below)...
{
"name": "Shop page",
"settings": [
{
"type": "header",
"content": "State"
},
{
"type": "select",
"id": "state_select",
"label": "Choose State...",
"options": state_list,
"default": "Alabama",
"info": "info text here"
}
]
}
and then (obviously) somewhere else, define that list. something like this...
var state_list = [
{
"group": "states",
"value": "AL",
"label": "Alabama"
},
{
"group": "states",
"value": "AK",
"label": "Alaska"
},
{
"group": "states",
"value": "AZ",
"label": "Arizona"
}
etc.
]
please - someone tell me this is possible!
You can't use variables in the schema object.
The schema objects accepts only JSON syntax and you can't pass any liquid variables in it.
This applies for the settings_schema.json file and the {% schema %} section.
You can't pass any liquid object, translatable strings or anything other piece of data that is not static text (a.k.a JSON object).
So if you are trying to do the following, it's INVALID:
{
"type": "select",
"id": "select",
"label": "Select",
"options": [
{{ select_options }}
],
"default": "option"
}
I have a service that is missing an element I require in my checkbox form - productUsed = false.
How can I push that into my json so it becomes part of the model for a form page for a series of checkboxes.
The json structure is similar to the below:
"Data": [
{
"AcceptedValues": [
{
"Category": {
"Key": 2126,
"Value": "Category"
},
"ProfileOptions": [
{
"Key": 46546798,
"Value": "product Name"
},
{
"Key": 46546769,
"Value": "product Name"
},
{
"Key": 2164,
"Value": "product Name"
}
]
},
{
"Category": {
"Key": 4646789,
"Value": "Category Name"
},
"ProfileOptions": [
{
"Key": 464987946,
"Value": "Product Name"
},
{
"Key": 132465,
"Value": "Product Name"
}
]
}
]
}
]
If the value is always false (at the moment) you can directly bind it in the view : {{product.productUsed}}.
If a property does not exists, Angular sets up a new property on the scope instead (default value is false i guess)
If the data is edited later, this code will works well.
//let suppose the $scope.recordlist is the original json
$scope.UpdatedRecordlist = $scope.recordlist.map(function(obj) {
return angular.extend(obj, {productUsed:'false'});
});
// Now $scope.UpdatedRecordlist is the new updated json with productUsed element