Contentful logo

Contentful Community

How to link an entry reference using a ui-extension field

Hi everyone!
I’m creating an ui-extension and I would like to be able to add a linked entry to an ui-extension field. The same thing that is doing contentful out the box when we are creating a new field of the reference type.

I need to know which JSON value I have to pass in the setValue method:
window._cfExtension.field.setValue (“some JSON value goes here…”);

I need to pass a JSON entry reference but I don’t know which is the structure to pass to do a link.

Any idea?

Thxs in advance

Hey Antonio,

Does this help?

:point_down:t2:

Cheers. :slight_smile:

1 Like

Hi Stefan!
Thxs in advance
I’ve already seen it. As a first step, yes, it’s useful.
But my link is from another space, so I have to provide the space part, and I don’t know how to add it.
cheer!

There isn’t an easy way to reference content between spaces. You’d need to have a CMA token with access to the other space in the UI extension and both space’s API tokens and custom logic to resolve the link on the front end as our API won’t resolve cross space links. Using our standard reference links won’t work.

Hi @Stefan,

Came across this while searching for how to update a linked entry. I have a similar situation, but with a many reference (so a list of those). My json looks like below, but the sdk returns a very useless error message back, and doesnt seem to set the value

request
[
{
“sys”: {
“id”: “id_of_linked_entry”,
“linkType”: “Entry”,
“type”: “Link”
}
},
{
“sys”: {
“id”: “id_of_linked_entry”,
“linkType”: “Entry”,
“type”: “Link”
}
},
{
“sys”: {
“id”: “id_of_linked_entry”,
“linkType”: “Entry”,
“type”: “Link”
}
}
]

response on calling setValue(request)

{“code”:“ENTRY UPDATE FAILED”,“message”:“Could not update entry field”,“data”:{}}

Any pointers as to why this can happen? I have write access to the field.

Cheers,
Bliss