Hello!
In the power apps formula I want to use the JSON function to convert JSON into a string, but the following error occurred.
Error
Formula
JSON([
{
colorType: 6,
display: "Source Type",
id: "SourceType",
operator: { display: "=", id: "COptionalEqual", valueType: 3 },
value: { id: [1], display: ["Pubmed"] }
},
{ display: "and", value: [{ display: "and" }] },
{
colorType: 1,
display: "All Fields",
id: "AllFields",
operator: { display: "Contain", id: "AllFieldsContain", valueType: 1 },
value: { display: "cancer" }
}
])
Solved! Go to Solution.
Hi @lusoftware :
Firstly,let me explain why you encounted this problem:
The key is that the data type of value is inconsistent.
value: {id: [1], display: ["Pubmed"]}
This means that the type of 'value' is object
value: [{ display: "and" }]
This means that the type of 'value' is array
Secondly,you can try:
JSON([
{
colorType: 6,
display: "Source Type",
id: "SourceType",
operator: { display: "=", id: "COptionalEqual", valueType: 3 },
value: { id: [1], display: ["Pubmed"] }
},
{ display: "and", value: {display: ["and"] } },
{
colorType: 1,
display: "All Fields",
id: "AllFields",
operator: { display: "Contain", id: "AllFieldsContain", valueType: 1 },
value: {display:[ "cancer"] }
}
])
In addition,Json is a Behavioral formula.I suggest you use a buttion, store its value in a variable, and then call the variable directly.For example:
Add a button and set it's OnSelect property to
Set(myvar,JSON([
{
colorType: 6,
display: "Source Type",
id: "SourceType",
operator: { display: "=", id: "COptionalEqual", valueType: 3 },
value: { id: [1], display: ["Pubmed"] }
},
{ display: "and", value: {display: ["and"] } },
{
colorType: 1,
display: "All Fields",
id: "AllFields",
operator: { display: "Contain", id: "AllFieldsContain", valueType: 1 },
value: {display:[ "cancer"] }
}
]))
Best Regards,
Bof
The JSON() function is for output data structures like collections and tables as as JSON string representation. Its not really designed to work with ad-hoc data structures like the one you are embedding.
Hi @lusoftware :
Firstly,let me explain why you encounted this problem:
The key is that the data type of value is inconsistent.
value: {id: [1], display: ["Pubmed"]}
This means that the type of 'value' is object
value: [{ display: "and" }]
This means that the type of 'value' is array
Secondly,you can try:
JSON([
{
colorType: 6,
display: "Source Type",
id: "SourceType",
operator: { display: "=", id: "COptionalEqual", valueType: 3 },
value: { id: [1], display: ["Pubmed"] }
},
{ display: "and", value: {display: ["and"] } },
{
colorType: 1,
display: "All Fields",
id: "AllFields",
operator: { display: "Contain", id: "AllFieldsContain", valueType: 1 },
value: {display:[ "cancer"] }
}
])
In addition,Json is a Behavioral formula.I suggest you use a buttion, store its value in a variable, and then call the variable directly.For example:
Add a button and set it's OnSelect property to
Set(myvar,JSON([
{
colorType: 6,
display: "Source Type",
id: "SourceType",
operator: { display: "=", id: "COptionalEqual", valueType: 3 },
value: { id: [1], display: ["Pubmed"] }
},
{ display: "and", value: {display: ["and"] } },
{
colorType: 1,
display: "All Fields",
id: "AllFields",
operator: { display: "Contain", id: "AllFieldsContain", valueType: 1 },
value: {display:[ "cancer"] }
}
]))
Best Regards,
Bof
Thanks, I know this is a bad way to use.
User | Count |
---|---|
199 | |
121 | |
84 | |
50 | |
41 |
User | Count |
---|---|
283 | |
157 | |
134 | |
73 | |
72 |