I’m going crazy trying to do something which I’m sure is very simple. I want to show or hide items on a dynamic page depending on the contents of a dataset field.
I’m trying to use wix-data get() or wix-dataset getCurrentItem()
Let’s assume I’m using them correctly and the dataset is definitely loaded (correct use of the Promise or onReady())
In both cases I end up with an object that - I think - is one row of data.
I simply want to extract one field from this row and convert it to a string to control whether or not things are hidden or visible with javascript. I’ve looked through tons of examples and forum posts and nothing seems to work.
Put simply, how do I return a string that is the contents “name” of below?
itemObj:
{
“_id”: “fcec780a-3e37-4b64-8a66-37c552c53f99”,
“_owner”: “f6c0f9c3-a62d-7e9f-g58d-943829af244d9”,
“_createdDate”: “2017-05-01T17:19:03.823Z”,
“_updatedDate”: “2017-05-01T17:19:10.477Z”,
“title”: "Dr. ",
“name”: “B”,
“link-dynamic-name”: “/myCollection/B”
}
Hello
If you have the itemObj then you can return the name by using itemObj.name .
However, if that’s not what you meant, would you please explain your issue more and provide some code, screenshots, or your website’s link to help me understand more 
Best
Massa
Maybe “name” wasn’t the best example. Is itemObj.name the name of the object, or the contents of the “name” field in the array?
I’m assuming that the object returned by the method is an array of name / value pairs? All I want to be able to do is extract one of them as a string. For instance if I wanted to print out the value of “_updatedDate” onto my page, how would I do so? Whenever I try to use toString() or whatever it just outputs “Object”
The pages on the site in question are password-protected, it is for club members only. I’ve only been working with code snippets so far, it seems like it should be a simple thing to do but maybe I’m misunderstanding.
OK I’ve found the problem, and like I suspected it’s very simple. Thank you Massa for trying to help.
I was using the field names instead of the field keys. D’oh!!
Here is the code snippet that works:
$w.onReady(function () {
$w(“#dynamicDataset”).onReady( () => {
let itemObj = $w(“#dynamicDataset”).getCurrentItem();
$w(‘#text63’).text = itemObj.tba_no;
} );
});
For “tba_no” I was entering the field name “TBA_No” from the database not remembering that the key was different - I built it a while ago. So like I thought, a very simple problem, your suggestion put me on the right track. Thanks again.
Have you figured this out mate? having the same issue too.