Hello,
I have been using REACT for a short time. Now, I have specific needs and I cannot find examples to move forward.
My need is the following:
I have a “Person” entity with the attributes “name” and “Firstname”…
I want to make a request to find a single record by searching on the “name” attribute (example name = ‘Kelly’.
I looked at what I could do with dataInstanceStore but I can’t do it without passing it the ID of the record I’m looking for (which I don’t know in my context).
By using collectionDataStore, I manage to pass the filter on the “name” attribute to it, but I have trouble exploiting the result. Indeed, I do not know how to access the values of the attributes.
Can you confirm the correct method for me and give me an example if you have one.
With thanks
It appears you never got an answer. I have a very similar problem. I’ve done the query on the collection and received at least one item back. I know because I’ve logged the id field and the log shows a value. I’ve tried adding an instance for the record I actually want and then a load call on that instance (Webuser), but it does not work either.
if (this.webUsers.items[0].id != null) {
this.webUser = instance<Webusers>(Webusers.NAME, {
view: "_local",
loadImmediately: false
});
console.log("ID to load is: " + this.webUsers.items[0].id);
this.webUser.load(this.webUsers.items[0].id);
}
Not sure I can isolate this code from the issue, but I’m getting closer. FYI, this is version 7.2.10 of the platform. I’m still not getting the entire entity loaded. It seems like it is loading “_minimal” rather than “_local”, even though I specify that as the view. Here’s the entity code:
I filter in a collection, then load the first item in the collection. That’s the only way I’ve found to get a search on a non-ID field to complete. I did try view: “_local” on the collection, but it did not load the entire view either. Obviously I would like to remove the second round trip.
Why are my fields not loading based on the view?
I will try to generate a minimal example, but I really am a noob at React so I’m not sure I can.
As you can see, I only got back the ID and no other fields. To test, I added an instance name to the webusers entity and tried again. My json came back the same, so it is not even including the instance name.
Is this the way it is supposed to work? Collections only return IDs and not the entire view? That makes no sense or your browse windows wouldn’t work, right?
I did do an “npm run update-model” to make sure my model was updated. I did not see any change in the entity .ts file. How does it even know the instance name? But that’s a question for another day…
I think I finally solved this. In order to get the attributes of the entities, I had to go into the Security Roles and create a rest-user-access Role. In that Role, I had to go into the Entities tab and click the Read checkbox in the upper right - Allow all Entities. That got me access to the entities, but NOT THEIR ATTRIBUTES!
I then had to go into the Attributes tab and click the Read-Only checkbox in the Allow all attributes box on the upper right.