Problems with bulk actions

I have…

  • Read the following guideline: Troubleshooting and Support | Squidex. I understand that my support request might get deleted if I do not follow the guideline.
  • Used code blocks with ``` to format my code examples like JSON or logs properly.

I’m submitting a…

  • Regression (a behavior that stopped working in a new release)
  • Bug report
  • Performance issue
  • Documentation issue or request

Current behavior

Hi Sebastian, we are having a couple problems trying to bulk change a field in a schema, using the api given https://…/api/content//notizia/bulk posting a simple request to reset a reference field to NULL results in a positive response on the server, i.e:

[
    {
        "jobIndex": 0,
        "id": "501cf192-09f1-4d27-80f8-e7dda66c9283",
        "contentId": "501cf192-09f1-4d27-80f8-e7dda66c9283"
    }
]

but I’ve noticed that none of the articles references have changed and that the jobindex doesn’t actually increase. From time to time the id and contentId do change though. Do you have any suggestions?

Expected behavior

I expect to see reference columns empty.

Minimal reproduction of the problem

Using the following via “Postman” /schema/bulk as recommended in the API
image

Environment

App Name:

  • Self hosted with docker
  • Self hosted with IIS
  • Self hosted with other version
  • Cloud version

Version: 7.6.1

Browser:

  • Chrome (desktop)
  • Chrome (Android)
  • Chrome (iOS)
  • Firefox
  • Safari (desktop)
  • Safari (iOS)
  • IE
  • Edge

Others:

Where do you have “Type” 4 from?

I actually had a look into the api, but I had only put it in as a test various calls to see if it would work.
Let’s call it a last ditch effort to try and get it to work after a numerous of attempts.
Previously I hadn’t put any variables apart from Patch: true, Data and Query.

Do you know if the problem is null or bulk in general?

the problem is bulk in general

I need something to reproduce. I have integration tests for bulk updates, which work fine.

I added a test, just to be sure: https://github.com/Squidex/squidex/blob/master/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.cs#L880

Ciao Sebastian,
I was able to execute the bulk action.
I noted that if i didn’t specify the
“expectedCount”: 123
variable in the payload the bulk would only execute for the first record and not loop till the end.
Given this might be the case i can put the expectedCount in by hand.

I do have another question with relation to the bulk action though.
If per say I have a field (TAG or TOPIC) how would I be able to “add” a value without deleting the current values. example

{
 id:123,
 topic.iv: ["apple", "pear"]
},
{
  id: 456,
  topic.iv: ["orange", "pear"]
},
{
  id: 789,
  topic.iv: []
}

but i need to add “banana” all of them, how may I do this?

  "data": {
      "topic": {
          "iv": ["banana"]
      }
  }

will overwrite all values.

Lannie

This is not possible at the moment. It would require some update operations, but I am not sure how they should look like. Something like

"data": {
      "topic": {
          "iv": { "$add": ["banana"] }
      }
  }

or a javascript expression like

"data": {
      "topic": {
          "iv": { "$update": "[...$ref, "banana"]" }
      }
  }

I am open to implement something like that.

I am working on this update feature at the moment. This is how it works:

  1. Instead of the actual value, you can use an object with the following shape:
"data": {
      "topic": {
          "iv": { "$update": "JAVASCRIPT" }
      },
      "title": {
          "iv": { "$unset": true }
      }
  }

The javascript has two arguments:

  • $data : The existing data.
  • $self: The current object that contains the $update.

This allows a few thins, for example

Just increment the number

"data": {
      "number": {
          "iv": { "$update": "$data.number.iv + 1" }
      },
  }

Add a value to the a field

"data": {
      "number": {
          "iv": { "$update": "$data.number.iv + $self.addThis", "addThis": 123 }
      },
  }