Deleting multiple records UI Builder

NizamArif
Tera Contributor

Hi.

I have a user case where I want to delete multiple records from a table. I want to make use of the "Delete multiple records" data resource.

I execute the data resource in a client script as following:

 

function handler({api, event, helpers, imports}) {
 
    api.data.delete_ignorings.execute({
        'table': 'x_1390311_easy_r_0_ignorings',
        'encodedQuery': 'email=robot@gmail.com'
 
    });
}
 
I want to delete all records that have email value equal to 'robot@gmail.com'. The operation results as sucess, however no records are deleted. The expectation is 1 deletion.
 
What am I doing wrong?
 
Regards
Arif
 
#Uibuilder
#dataresources
#encodedQuery
4 REPLIES 4

Mark Manders
Tera Patron

You are going through these steps to delete one record? Just delete the record.

There could be cases where there are more then 1 record with them same email.

If it's a recurring thing, make a fix script for it:

var data = new GlideRecord('x_1390311_easy_r_0_ignorings');
data.addEncodedQuery('email=robot@gmail.com');
data.query();
while(data.next()){
    data.deleteMulitple();
}

Or consider using a before business rule: if email = robot@gmail.com, abort action.

Not applicable

Hi @NizamArif ,

Please check below solution 

Please add a data resource Delete Multiple Records

SarthakKashyap_0-1721981692547.png

 

Add one client script and attach that client script on any button or something you want to add 

SarthakKashyap_1-1721981709304.png

 

/**
* @param {params} params
* @param {api} params.api
* @param {any} params.event
* @param {any} params.imports
* @param {ApiHelpers} params.helpers
*/
function handler({api, event, helpers, imports}) {
    api.data.delete_multiple_records_1.execute({
        'table': 'x_1390311_easy_r_0_ignorings', // Your Table
        'encodedQuery': 'email=robot@gmail.com' // Your Query
    });
}

 

Please mark my answer correct and helpful if this works for you 

Thanks and Regards 

Sarthak