Script To Delete In Bulk

Posted by ithrees on 30-Mar-2017 07:16

Hi All,

How can I delete set of records that meet the condition in Rollbase? For example, If I want to delete all the records that has 'expired' status. 

I am looking for a better option then running a query to get the list of ids and calling 'rbv_api.deleteRecord' for each id.

Thanks in advance,

All Replies

Posted by on 30-Mar-2017 08:35

I've used batch jobs for these types of situations when considering a "single runtime" scenario or a "scheduled runtime" scenario. Makes life easier.

Just supply a simple condition

e.x. if ("{!status#code}" == "expired") rbv_api.deleteRecord([supply params here]);

For single runtime, don't deploy the batch job and just manually run it using "run now".

For scheduled runtime, deploy the batch job so it runs given its schedule.

Hope this helps you out.

Posted by ithrees on 30-Mar-2017 23:09


Thank you for your reply. This method is OK for the manual processing but in my case I have to include the deleting part inside the application scripts to execute it with the application logic. Something similar to SQL DELETE.


Posted by on 31-Mar-2017 02:51

I see [mention:afc197de55e94694a022d8d7d7518dc5:e9ed411860ed4f2ba0265705b8793d05]. Can you describe the use-case for me? Would it be something transactional such as you a create a record on a different object and specify the conditions for deletion and a server-side script would run to delete the records that match the criteria? If this is the use-case, I think the best way to go is still to use rbf_selectQuery() + rbf_deleteRecord(). It would most likely offer the best performance out of all the methods as per my experience.

If you were to work in the client-side, you would have access to getPage() which accepts a View's original ID and inherits the filters of the supplied view and will then return to you the records that match the view's filters' criteria. It's performance is poor for me though. Even when trying 5 records with this API i get really slow load times.

May I know why you are looking for a better option?

Hope this helps.

Posted by ithrees on 31-Mar-2017 05:53

Thank you,

I want to do this from the client-side. There is an UI page for planning in my application where I create many records in many tables. In certain cases I have to delete many records relate to that logic and after deleting I have to continue with something. As the response time is critical in this application It would be better to make a single call to delete all and do the rest in the callback rather than making too many calls to the server to delete each and then to continue.


Posted by on 31-Mar-2017 06:06

If you're page is purely code built, then I suggest you use the REST API > deleteArr()


It can delete multiple records with a single call and you can use jquery to do .ajax() or similar to invoke it.

Hope this helps.

Posted by ithrees on 02-Apr-2017 22:31

I think it is better to have similar bulk deleting api for both client and server side in future.

Posted by on 03-Apr-2017 00:43

You may also perform that API and other REST APIs in the server side using sendJSONrequest() I believe.

This thread is closed