Can a "Field Key" be a Variable?

What’s up, Gurus.

Is there a way to use a variable as a field key for a collection?

Here’s my code snippet:


function pageContent() {
    $w("#dataGAM").onReady( () => {
        $w("#dataGAM").getItems(0, 3)
          .then( (result) => {
            let items = result.items;
            $w("#richCon1").value = items[2].pg1A;
            $w("#richCon2").value = items[2].pg1B;
            });
    });
}

In this snippet, my field keys are “.pg1A” and “.pg1B”.

If a field key can be a variable, there’s a lot of fun stuff I can do. Just not sure if a field key can be a variable.

Let me know. And, if yes, may I have an example?

Oh, damn!

Figured it out using another Velo forum post – solution here .

In a nutshell, create the necessary variable(s). Then, for example, replace “items[2].pg1A” with “items[2][yourVariable]”.

You may then manipulate the variable as needed.

Happy coding!