I’m talking about the field ‘filterLocale’ that needs to point to another entry. But how? We cannot assign the id, because it’s a system property (sys.id), and it doesn’t seem like we can assign the entry object either.
I’m also trying to do something similar. I want to change entry link field to point to different entry. I’ve dug through the documentation of both the contentful cli and content management SDK. I’ve found the deriveLinkedEntries function to build a new entry based on content in the Entry but I have yet to find a way to simply change a link field to point to a different, existing entry.
This gets you a complete entry.
Entries are linked to each other not by full entities, but Link objects. They look like the following:
{
"sys": {
"type": "Link",
"linkType": "Entry ",
"id": "<use sys.id of the linked entity, e.g. localeEntry.sys.id>"
}
}
Assign these to your link field (mind that you need to specify the locale you want to assign the link to, so it would probably look more something like this:
Thanks Stephan, that’s what I was trying to do but I was getting an error due to using the local “en-Us” instead of “en-US”. The code sample for update entry us using “en-Us” and set me down the wrong path. Corrected the local and my entries updated.
Are there any plans to create a corresponding API point that would eliminate the need for constructing the sys object “by hand”? This should really be a one-liner with 2 parameters. If not, is there a place in the docs that breaks down this very common operation and makes it crystal clear? The current approach is far from obvious.
I understand my code could have been simpler, but my point still stands. You’re expecting users of your API to construct a system object with specific fields. This is an issue all over the place is the Management API, where without proper docs or a reply like this one, it could take hours (or days) to figure out.
I’m trying hard to do this entry linking in .Net
Is there an example of how to do this somewhere?
var childEntry = new Entry<dynamic>
{
SystemProperties = new SystemProperties
{
Locale = DefaultLocale
},
Fields = new
{
Name = WrapInLocale("I'm the baby"),
}
};
// leaving out the code where I create the child entry using the CMA client
var parentEntry = new Entry<dynamic>
{
SystemProperties = new SystemProperties
{
Locale = DefaultLocale
},
Fields = new
{
Name = WrapInLocale("I'm the parent"),
MyLinkedChildEntry = WrapInLocale(new Entry<dynamic>
{
SystemProperties =
{
Type = "Link",
LinkType = "Entry",
Id = childEntry.SystemProperties.Id
}
})
}
};