Re: How to update content without lost relationships?
So it looks like your query for the relationships field is incorrect. You're using the AND (&&) operator, which means that the query will only match content where the identifier is BOTH of those ids AT THE SAME TIME. Which obviously can't happen. Try changing the `&&` to `||` (or just removing it completely, since if you don't have that operator it will treat a space as an OR anyway).
One tip in general when working with queries: Try running the query in the Query Tool (in the dotCMS back-end) first to make sure it returns what you expect it to. If you run the query you're using now, you should find that it returns no results. Then try running it after removing the `&&` and make sure it gets back the two content items you expect.
(Note that you can just as easily use the REST API to submit the query using a REST call instead of using the Query Tool, but the Query Tool is generally faster to experiment with since it's interactive).
Hope it helps.
On Friday, December 22, 2017 at 8:40:02 AM UTC-8, mvelasco wrote:
I have two content types and a relationship 1: N
Content types: Promotion (parent), Version (child)
I didn't have any problem saving "Versions" but every time I save a Promotion I lost all previous relationships with Versions.
As documentation says <a href="https://dotcms.com/docs/latest/save-content-using-the-rest-api" rel="nofollow" target="_blank" onmousedown="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fdotcms.com%2Fdocs%2Flatest%2Fsave-content-using-the-rest-api\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH-c00glcETbGGwnthRDkuCX_xIqg';return true;" onclick="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fdotcms.com%2Fdocs%2Flatest%2Fsave-content-using-the-rest-api\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH-c00glcETbGGwnthRDkuCX_xIqg';return true;">https://dotcms.com/docs/latest/save-content-using-the-rest-api "When updating content using the REST API, you must submit all relationships for a piece of content each time you update the content."