Given a list of attribute element uri’s, what’s th...
# gooddata-ui
e
Given a list of attribute element uri’s, what’s the best way to get the text titles that they correspond to? Ex:
['/gdc/md/workspace/obj/14005/elements?id=15787', '/gdc/md/workspace/obj/14005/elements?id=15788', '/gdc/md/workspace/obj/14005/elements?id=15789']
->
['Bob', 'Sarah', 'Alex']
m
Hello @Evan Shen you can use
@gooddata/sdk-backend-bear
for this. Example code:
Copy code
async function getElementTitles(workspaceId: string, displayFormRef: ObjRef, elementUris: string[]) {
    const elementsResult = await backend
        .workspace(workspaceId)
        .attributes()
        .elements()
        .forDisplayForm(displayFormRef)
        .withOptions({
            elements: {
                uris: elementUris
            }
        })
        .query();
    
    const titles = elementsResult.items.map(i => i.title);

    return titles;
}
e
ah cool, didn’t know about the elements option. thanks!
h
What exactly do we need to pass as displayFormRef
e
I passed the displayForm ObjRef of the attribute these attribute elements belong to