How to show Error Message on table API

Upender
Giga Expert

Hi,

I have written business rule to show error message when user try to delete a record in the table. Its working fine, I can the error message on the Form.

But When I try to deleted record in the table by Table API in Rest API Explorer, doesn't show error message instead it shows message

"error":\{"detail":"Operation against file 'table name' was aborted by Business Rule 'business rule name^sysid'. Business Rule Stack:Abort Delete-","message":"Operation Failed

How can we show error message in table api?

 

Regrads,

Upender

1 ACCEPTED SOLUTION

Upender
Giga Expert

OOB there is no way to show error message on the table API.

Opened enhancement request with ServiceNow.

 

 

 

Regards,
Upender

View solution in original post

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Upender,

The validation which you are doing in the before delete business rule have the same code in the scripted rest api.

The Table API will show you the message as per the business rule logic you have written.

If you want to have custom message to be sent before deletion then use scripted rest api.

Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Unless something has recently changed, errors in business rules do not output to rest calls.  Can you provide an example of this doing this bawiskar?  I'd love to see this working the way you describe, but I haven't seen that work this way.

Hi Ankur,

I tried by creating Scripted Rest API, but no use still I see the same error message.

 

var del_system = current.u_monitoring_system;
var cluster_name = '';
var gr = new GlideRecord('cmdb_ci_cluster_node');
gr.addQuery('name', current.u_host.name);
gr.addQuery('install_status!=7^ORinstall_status=NULL');
gr.query();
if(gr.next()) {
cluster_name = gr.cluster.name;
//gs.addErrorMessage('name:' + cluster_name );
if(cluster_name != ''){
var mc_gr = new GlideRecord('u_monitoring_collectors');
mc_gr.addEncodedQuery('u_host.name='+cluster_name);
mc_gr.query();
while(mc_gr.next()){
if(mc_gr.u_monitoring_system == del_system){
current.setAbortAction(true);
return 'Error : Custom message ';
}
}
}
}

 

 

Regards,

Upender

Upender
Giga Expert

OOB there is no way to show error message on the table API.

Opened enhancement request with ServiceNow.

 

 

 

Regards,
Upender