I’m trying to create a list of available filters. ...
# gooddata-platform
I’m trying to create a list of available filters. Is there an easy way to get the Ldm through the SDK? I can find so little documentation about Ldm.
Hi Chris! Thanks for reaching out 🙂
By SDK I assume you mean the GoodData.UI JavaScript/React SDK? right?
If you'd like to "export the Ldm" (export the metadata objects like metrics, attributes, insights, …) into a JSON file, you can use the catalog export tool. It comes bundled with create-gooddata-react-app, so if you used that to start your GD.UI project, it should be ready. Look into package.json for
command (used to be
in earlier versions).
If you'd like to list some metadata objects directly in your source code using JavaScript, our SDK has methods you can use. Unfortunately, at this point the methods are only documented in the code – we're working on exporting all the docs into a nice HTML and expose it as part of our official documentation – but for now you can take a look at the source code and let your IDE intellisense help you.
Thank you!
I’m looking at this tool and noticed that we will be generating a static file. So the undocumented part would that make it dynamic?
Yes, the tool gives you a static file.
If you want something more dynamic directly in your source code, you can try something like this:
Copy code
import bearFactory, { ContextDeferredAuthProvider }from "@gooddata/sdk-backend-bear";
// import tigerFactory, { ContextDeferredAuthProvider } from "@gooddata/sdk-backend-tiger";

const backend = bearFactory(backendConfig).withAuthentication(new ContextDeferredAuthProvider());

backend.workspace('<workspace-id>').attributes().getAttribute(idRef("orderdate.year", "attribute")).then(console.log);
"Returns factory that can be used to query workspace catalog items - attributes, measures, facts and date data sets."
That looks like exactly what I need!
I’m trying this example from the docs:
Copy code
                    filter={newNegativeAttributeFilter(Ldm.EmployeeName.Default, [])}
However, whatever attribute I try that I get from the call you just gave me. It doesn’t seem to load, I keep getting “Error loading filter”.
Am I getting the wrong attributes here?
The example you are trying is actually using the static exported catalog into JSON file. That
variable is exposing the JSON file in your source code.
Do you know the identifier of the attribute you'd like to use?
It seems there's two problems you're trying to solve simultaneously, 1️⃣ dynamically list all the available attributes, and 2️⃣ create a functional AttributeFilter based on a specific attribute.
We should resolve them one by one. Which one would you like to tackle first?
I think 2 would be easy once I have 1. So any help with #1 would be amazing
Alright, let's tackle #1 first 🙂
Do you know the identifier of the attribute you'd like to use?
Let's try to make it work with a hardcoded identifier first, and then we can try to retrieve it dynamically.
I’d prefer to get all that are available. But I have an identifier called
that I know works
Really appreciate all your help btw
And this identifier works with your AttributeFilter component?
You can see list all available attributes also by visiting
This identifier works with the filter yes. I just called that URL, and surprisingly the
is not in there.
And none of the identifiers seem to work
Please make sure that you are supplying an attribute label (=displayForm), not the attribute itself.
You are looking for an attribute displayForm identifier, not the attribute identifier.
Screen Shot 2021-07-29 at 14.31.21.png
😱 That worked!
🎉 1
Yay! 👏
Thanks for all your help Jiri
Happy to help Chris!