#✅ primaryKey for interface is `+` instead of id for item.

5 messages · Page 1 of 1 (latest)

robust canyon
#

Greetings!

I'm building an interface and trying to get the primaryKey of the item. When I open the item, the primaryKey has a value of +, which would be expected if this item weren't already assigned an ID.

Another interesting thing about this is that it only happens if I open the item directly through the items collection page. I have another collection that has a o2m relationship with the items collection. When I use the o2m interface to access the item, the interface I'm building has the ID of the item as the primaryKey, as expected. (to be clear, this is when the item is pulled up in the side panel, and not accessed directly)

Any thoughts on why I'm getting the wrong primaryKey when accessing the item directly?

spare ivyBOT
#

Thanks for posting! This is a community powered server, so you may or may not get an answer based on available help and expertise. To increase your chances of somebody being able to help you, please help us help you making sure you:

  • Adding an explanation of exactly what you're trying to achieve.
  • Adding any and all related code or previous attempts.
  • Describing the exact issue or error you are facing.
  • Posting any screenshots if applicable.
  • Reading through https://stackoverflow.com/help/how-to-ask.

When you're done with this thread, please close it. Thanks! ✨

(If you have a support agreement and need help, please contact the core team via email.)

toxic rampart
#

How the way you get the primaryKey?
AFAIK, + sign mean that you are on creating a new item phase

robust canyon
robust canyon
#

I figured it out. In case anyone else is having the same issue, the problem was that the primaryKey is loaded after onMounted is called on the items page. I used logic in onMounted that required the primaryKey to be accurate.

To work around this I used a watcher on props.primaryKey that would execute the logic when the primaryKey was changed.