How to access data stored in enum/name via query

I’m stuck with the syntax to access necessary to access data in an enum/name lookup type. Below is an example of the a query.

const assessments = await fibery.executeSingleCommand({
            "command": "fibery.entity/query",
            "args": {
                "query": {
                    "q/from": "Project Management/Assessment",
                    "q/select": [
                        "fibery/id",
                        "Project Management/name",
                        "Project Management/Effort",
                        {
                            "Project Management/Task Template Type": [
                                "fibery/id",
                                "enum/name"
                            ]
                        },
                        {
                            "Project Management/Rating": [
                                "fibery/id",
                                "enum/name"
                            ]
                        }
                    ],
                    "q/where": ["=", ["fibery/id"], "$id"],
                    "q/limit": "q/no-limit"
                },
                "params": {
                    "$id": "698c7753-2b43-4520-98f8-420b4c866c2a"
                }
            }
        })
        for (const assessment of assessments) {
            console.log(assessment["Project Management/Rating"]);
        }

This will properly output to console the expected results.

{
  'fibery/id': '36aa4e11-3885-11ed-8e5d-fb8807c01281',
  'enum/name': 'DevOps Stage 1'
}

I can’t figure out how to access that enum/name though. I’ve tried what I believed would be the right syntax and have iterated on it in all possible ways I could think of that might work, yet none have. 2 example attempts

  console.log(assessment["Project Management/Rating"]["Name"]);
  
  console.log(assessment["Project Management/Rating"].Name);

  console.log(assessment["Project Management/Rating"]["enum/name"]);

I get an error something like: “Cannot read property ‘Name’ of null”.

What is the proper way/syntax to access this lookup data?

I’ve read through all the forums and searched for possible solutions but I haven’t found any yet. Many thanks in advance!

Out of interest, have you thought about solving the same problem using no-code actions? It is possible to query the Assessment database using formulas in automation.
Or even just using getEntityById instead of executeSingleCommand…?

Yes of course, I always look for the nocode path with Fibery first. This is being used to create some add some documentation into the description field mixed with markdown.

I previously created a massive make.com / documint.me integration to create reports based off the data stored in Fibery. It’s a massively complex machine that I want to move away from and simplify. I’m now trying to build something similar within Fibery instead so at the press of an automation button the various aspects of the project and assessments are collected and a report document is created.

Is there something inherently wrong with the path I’m taking above?

Thank you @Chr1sG. I tried a similar logic structure, replaced the query with getEntityById and the fields needed and totally allows what I needed. Thank you. Initially I tried it and wasn’t getting the results I wanted but obviously that was mainly a problem at the keyboard. :slight_smile:

I don’t know exactly what you’re trying to achieve, but have you thought of doing something like this:

1 Like

Yes thank you @Chr1sG. Your suggestions and knowledge are so awesome and I appreciate all the posts you make. I am learning so much from you and the rest of the community.

I was specifically having issues calling deeply related content. For example only.

Projects

  • Belong to one Account
    – Each account has many contacts
    — each contact has many meetings
    ---- each meeting has many action items.
  • Has many assignees and employees
  • Have many Tasks
    – Each task has one to many contacts
  • Have many Assessments
    – Each assessment has a Rating
    – Each assessment has a RICE score
    – Each assessment has rich text for Description, Findings, Recommendations, Concerns
    – Each assessment has artifacts assessed
    — Each artifact has a repository, a technology type, and best practices
  • Have many Summary Reports
    – Each Summary Report has rich text sections for Description, Summary, Details.

I pull details from all these relationships and build markdown reports from the content. I was running into issues with async calls within various different types of javascript loops. I’m re-learning javascript after 10 years away from it and this issue lead me initially to try and build complex queries through the API. With your suggestion and figuring out how to properly use iteration with async I’ve finally broke the difficulty barrier and am starting to find my flow and ease in working with the Fibery scripting capabilities. Fibery is literally the only product I’ve found that has the power and feature set to build these amazing data driven text based templates. I know there is so much more to discover too. Thank you again!

Glad we could help, and happy to hear your making progress.

In case it’s of interest, we also have a GraphQL API which might be useful for you:

Thanks again @Chr1sG! I initially stated with GraphQL attempts but quickly realized my skill with that needs more growth than my javascript. lol. I couldn’t figure out the syntax for dynamic queries but will dive into it more in the coming weeks.

1 Like