- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2017 09:11 AM
Hi Guys,
My requirement is to enter a valid value in reference field using Rest API.
For that I have created a Data Policy which is not working, if I enter invalid value or value not in reference table, record is created in the table with a null or empty value with Response Status code as 201 Created.
Even I tried to create business Rule. Record is created giving Response Status code as 201 Created and it is throwing an error on UI side if I enter invalid value.
I have created a Data Policy on another choice field on the same table which is working fine it is giving Response Status code as 201 Created If I enter a valid choice. If I enter a choice other than choices in the field it throws an error with Response Status Code 403 Forbidden.
Is there is a way to make a reference field Mandatory for Rest API.
Thanks in advance
Upender
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-16-2017 09:01 AM
I have created a business rule to check if the value enter in reference field is present in the reference table or not. if the value not present in reference table don't allow to create the record in the table.
var a = [];
var gr = new GlideRecord ('u_mon_collector_config'); //Reference table
gr.query();
while(gr.next()){
a += gr.sys_id;
}
if((a.indexOf(current.u_monitoring_system) == -1) || (current.u_monitoring_system =='')) //Reference field
{
gs.addErrorMessage("Fill in valid value in Monitoring System field");
current.setAbortAction(true);
}
Regards,
Upender
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2017 09:23 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2017 09:41 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2017 10:12 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2017 10:25 AM