Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relationship fields couldn't update with workflow apis #24167

Closed
waqasakramdot opened this issue Feb 20, 2023 · 5 comments · Fixed by #24284
Closed

Relationship fields couldn't update with workflow apis #24167

waqasakramdot opened this issue Feb 20, 2023 · 5 comments · Fixed by #24284

Comments

@waqasakramdot
Copy link

waqasakramdot commented Feb 20, 2023

Problem Statement

When workflow action apis use to update/add relationship fields for a contentlet then there are two behaviors occur.

  1. It returns a message with Exception If space uses between queries.
    Example:
"contentlet": {
    "regions":"(+contentType:Region) +identifier:994d34aaf93f98c90a666d6fef537812"
  }
  
  OR
  
   "contentlet": {
    "regions":"(+contentType:Region) +Region.title:('PSGNU058')"
  }

Response:

{"message":"The map contains an invalid value: class com.dotmarketing.portlets.structure.model.ContentletRelationships"}

2: It returns contentlet data but didn't update relationship field however the last update date change for contenlet

Example:


 "contentlet": {
  "regions":"(+contentType:Region)+Region.title:*Asia*"
  }


Response:
Contenlet data in json -- Omit that response for bravery

Steps to Reproduce

Create two contenttypes e.g Movie, Region

Create a relationship field one-to-many in Movie with Region

Create two Region contentlets e.g Asia, Africa

Create a contenlet of Movie and don't assign region to it yet because try to add with Workflow API

At last do REST api call with correct identifier and inode

curl -X 'PUT' \
  'https://demo.dotcms.com/api/v1/workflow/actions/b9d89c80-3d88-4311-8365-187323c96436/fire?identifier=33c53dd87135947b76147a347a765424&language=-1' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "contentlet": {
    "regions":"+contentType:Region +Region.title:*Asia*"
  }
}'

Acceptance Criteria

If REST body is correct then Workflow REST api should update relationship field according to data otherwise should return meaning full error response.

dotCMS Version

23.0.1

Proposed Objective

Customer Support

Proposed Priority

Priority 2 - Important

External Links... Slack Conversations, Support Tickets, Figma Designs, etc.

https://dotcms.zendesk.com/agent/tickets/110108
https://dotcms.zendesk.com/agent/tickets/113060

Assumptions & Initiation Needs

No response

Sub-Tasks & Estimates

No response

@fmontes
Copy link
Member

fmontes commented Jul 18, 2023

Needs to check the PR

@fmontes
Copy link
Member

fmontes commented Jul 18, 2023

@jcastro-dotcms Please check the PR, fix the conflicts, run the tests and let's internal QA this.

fmontes pushed a commit that referenced this issue Aug 23, 2023
* Allowed ContentletRelationships type to be copied for contentlet

* Added postman tests for issue 24167

* Updated postman tests description + added incomplete IT

* #24167 getting complete the curl test

* #24167 adding unit test

* Merging `Workflow Resource Tests.json` with latest version in `master`.

---------

Co-authored-by: jdotcms <jonathan.sanchez@dotcms.com>
Co-authored-by: Jose Castro <jose.castro@dotcms.com>
@erickgonzalez erickgonzalez reopened this Aug 28, 2023
@waqasakramdot
Copy link
Author

A customer is hitting this indirectly. https://dotcms.zendesk.com/agent/tickets/113060

@jcastro-dotcms
Copy link
Contributor

INTERNAL QA: PASSED

Relationship fields can be successfully updated via the Workflow API now. Here are the steps to reproduce:

  1. In your docker-compose.yml file, set the following environment variable:
DOT_CONTENT_APIS_ALLOW_ANONYMOUS: 'WRITE'
  1. Create a Content Type called Region with the following field:
    2.1 Text field named Title.
  2. Create another Content Type called Movie with the following fields:
    3.1. Text field named Title.
    3.2. Relationships field named Regions, pointing to the Region type and selecting the One to many cardinality.
  3. Create two Contentlets of type Region:
    4.1. Title = Asia
    4.2. Title = Africa
  4. Create a Contentlet of type Movie with the title My New Movie, but DO NOT ADD any Region to it, as it'll be added via cURL.
  5. Copy the Identifier of the My New Movie Contentlet and paste it in the following cURL command:
curl -X 'PUT' -u "admin@dotcms.com:admin" \
  'http://localhost:8080/api/v1/workflow/actions/b9d89c80-3d88-4311-8365-187323c96436/fire?identifier=<CONTENTLET_IDENTIFIER_HERE>&language=-1' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "contentlet": {
    "regions":"+contentType:Region +Region.title:*Asia*"
  }
}'
  1. Check the My New Movie Contentlet in the dotCMS back-end, and make sure it's related to the Asia Region now.

@bryanboza
Copy link
Member

Fixed, tested on master, following the provided steps and now it is working as expected
image

@erickgonzalez erickgonzalez added the LTS : Next Ticket that will be added to LTS label Sep 22, 2023
@erickgonzalez erickgonzalez added Next LTS Release and removed LTS : Next Ticket that will be added to LTS labels Nov 10, 2023
erickgonzalez added a commit that referenced this issue Nov 16, 2023
erickgonzalez added a commit that referenced this issue Nov 16, 2023
@erickgonzalez erickgonzalez added the Release : 23.01.9 Included in LTS patch release 23.01.9 label Nov 27, 2023
erickgonzalez added a commit that referenced this issue Nov 30, 2023
@erickgonzalez erickgonzalez added Release : 22.03.12 Included in LTS patch release 22.03.12 and removed Next LTS Release labels Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.