Hi all. I am trying to filter iframe component usi...
# gooddata-cloud
g
Hi all. I am trying to filter iframe component using dashboard commands and using positiveAttributeFilter using the postMessage command and sending this message: document.getElementById("embedded-app-frame").contentWindow.postMessage({ "gdc":{ "product":"dashboard", "event":{ "name":"setFilterContext", "data":{ "filters":[ { "positiveAttributeFilter":{ "displayForm":{ "identifier":"spaceType2.name", "type":"dataset" }, "in":[ "Auditorium " ], "label": {"identifier": {"id": "spaceType2.name", "type": "label"}}, "textFilter":false, "selectionMode":"multi" } } ] } } } }, "*") and I get the following error: The command has invalid attribute or date data format The error is indeed in the attribute, and when I'm creating negativeAttributeFilter with notIn:[] it works fine. So my question is, what am I supposed to send as data to the positiveAttributeFilter in the "in" section. In the documentation, I have found that I have to send something like: /gdc/md/kr3t3bca94asl/obj/400/elements?id=12
j
Hi Goran, are you working with embedded visualizations? using this thread and the previous thread ?
g
Hi Joseph, yes I am working with embedded visualizations using iframe and postMessage to get the filtering
The date filter is ok now, just the attributeFilter is showing invalid attribute or date data format, when I try to send filtering values
j
Hi Goran, Are you using the correct format of an attribute in GoodData Cloud? You can find the attribute ID in Logical Data Model. It should look like on the below example:
g
Hi @Julius Kos I am using the correct attribute ID in the LDM. When I try negativeAttributeFilter with notIn:[] it works. When I try to add any value either in positiveAttributeFilter with "in:[...]" or negativeAttributeFilter with "notIn:[...]" i get the error The command has invalid attribute or date data format. I tried with id and with name, I can see the event response when I use it from the filter component, it is the same values but I get error
j
Hi Goran, is there a traceID or the exact error message you are seeing so we can also check our logs? Furthermore, you say it works when using notIn:[]. If you remove the “” from the “in:[...]” does it work as well? Could you provide the body of the working statement using notIn:[] ?
g
Hi Joseph, the structure of the message in postMessage that works is: document.getElementById("embedded-app-frame").contentWindow.postMessage({ "gdc":{ "product":"dashboard", "event":{ "name":"setFilterContext", "data":{ "filters":[ { "negativeAttributeFilter":{"displayForm":{"identifier":"spaceType2.name","type":"displayForm"},"notIn":[]} } ] } } } }, "*")
The error output of the possitiveAttributeFilter is:
j
Hi Goran, it looks like there might be an extra “space” in “Auditorium ” and I don’t think the dataset is needed. could you please try with the following:
Copy code
{
  "positiveAttributeFilter": {
    "displayForm": {
      "identifier": "spaceType2.name"
    },
    "in": [
      "Auditorium"
    ],
    "textFilter": false,
    "selectionMode": "multi"
  }
}
g
Hi Joseph, I have tried it without the space, removed the dataset, used another field (LocationName), still the same error. The thing that bothers me most is that with negativeAttributeFilter it works with empty array. Once I insert a value, it gives error. I have ran out of ideas to try about this and it is important to have filters outside the embedded dashboard
j
Hi Goran, would you please try to change
textFilter
to
true
? E.g.
Copy code
"textFilter": true,
I believe that is the root cause. Values for
in: []
and
notIn: []
should be the desired attribute values as they are displayed, for example in insight.
g
Hi @Jan Kos Thank you for this, with textFilter set to true did the fix. Thanks