Export user records conditionally

Hi,

I’m wondering if there is a way to export user data records, for example if they meet some condition such as created data > some day, or a boolean field is true.

Follow up, is there a way to set all records value? Like set all “sent” fields to true?

-Andrew

Hi Andrew,

Yes, it is possible. To do this, login to Backendless Console, click the Data icon, and select the Users table. Run a query in the search field, for instance:

sent = true

Console will display all objects that meet the specified criteria. In the More drop down, select Export:

The exported file will be in the Backendless File storage of your app. To get the file click the Files icon and click the export directory:

Locate the file with the timestamp that corresponds to the time when you initiated the export.

Regards,
Mark

Mark,

That’s great, thanks! Then is there a way to set all field values sent = TRUE?

-Andrew

Hi Andrew,

Yes, there is a way. To update multiple objects with a single request using Backendless Console, you can do the following:

  1. Make sure the Users table is selected.
  2. Click the REST Console tab.
  3. Click the Bulk Operation checkbox.
  4. Enter the following into the Where field:
    sent = false
    
  5. Enter the following into the Request Body area:
    { 
      "sent":true
    }
    
  6. Click the PUT button.

The Response body area will show you the number of user records that have been updated.

A little explanation:

  • step 3: a bulk operation updates multiple objects in a single command
  • step 4: in here you define the condition for which user records to be updated
  • step 5: this is a JSON object that contains the changes to be applied (meaning for all objects identied in step 4, apply the change from 5

Hope this helps.

Regards,
Mark

1 Like

Hi Mark,
I’m revisiting this topic from a while ago. When I follow the steps for the bulk (or single) update, I get this response:
{
“code”: 3011,
“message”: “Property ‘password’ is required”
}

So I tried add the password in the request, like “password”:“mypwd”, then I get this response
{
“code”: 3078,
“message”: “You can not register user without the ‘email’ property value while ‘Require Email Confirmation’ is enabled”
}

Any ideas on what I am doing wrong?

Thanks

Hi Andrew,

Without seeing what you’re doing, I cannot tell you more than what the error message already says.

The second error is referring to the following:
https://backendless.com/docs/rest/users_user_registration.html#email-confirmations

Regards,
Mark

Hi Mark,

On the first one, I was just following the steps that used to work to do a bulk change of a database but I don’t know why it would ask for password when I am logged in.

Here’s the screenshot

What button did you click on that screen? (to get the response as shown in the screenshot)

Put

If I understand correctly, you want to update all user records that have the emailSent column set to false in the database and change its value to true. To make this a bulk update operation, click the Bulk Operation checkbox to the right of the DELETE button.

If the checkbox is not selected, clicking the PUT button will be interpreted as an “update of a single object”. With the provided data, a single object is not identified at all. Therefore, the system performs the general requirements check and says that the password property must be specified in the payload. It has nothing to do with your password; the error relates to the REST request you made.

Great thank you! I thought I would just try a small test case but now that I select bulk it worked.

Have a great day!