- 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 10:44 AM
Hi Upender,
When you use rest api to insert a record in that table not in the reference table so insertion of record data policy check that it's having the value or not
In Reference table data is not match with any record it will create a new record in reference table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2017 10:52 AM
Hi Chandu,
I checked Reference table no record is created in two weeks. So reference table is not storing new values (invalid values enter through Rest API).
Regards,
Upender
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2017 07:56 PM
you want to restrict those values insertion through rest api
When a record insertion automatically (rest ,soap. data source,scripts) it only check with form having the value will not check for the it's having the valid data or not
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2017 06:46 AM
HI Chandu,
I want to restrict creation of record in table if the User enters value in reference field, value that is not present in the reference table through rest, soap, data source or Scripts.
Is there is a way to do this
Thanks,
Upender
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2017 08:21 PM