- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2024 05:09 PM
I am wondering if someone can assist with script to post a record producer.
We want this scripted rest API for just 1 record producer and only 5 fields.
I have done for the incident but have no knowledge on how to create one for the record producer. How to call the record producer and variables etc.
Any guidance will be appreciated.
Thanks,
G
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2024 06:50 AM
As an FYI, that sort of information is beneficial to include in your original question in future.
Similar to the REST API, there is an js API you can use. CatItem | ServiceNow Developers. It can be combined with a scripted REST API.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2024 12:23 AM
HI @GB14 ,
try this :
for variables you can try this :
var variable1 = body.variable1;
var variable2 = body.variable2;
and use setvalue to set the value to variables...
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
// Parse the incoming request body
var body = request.body.data;
var short_description = body.short_description;
var description = body.description;
var producer = new GlideRecord('my_record_producer_table');
producer.initialize();
producer.setValue('short_description', short_description);
producer.setValue('description', description);
var producerID = producer.insert();
if (producerID) {
response.setStatus(201);
response.setBody({
"status": "success",
"message": "Record producer created successfully",
"producerID": producerID
});
} else {
response.setStatus(500);
response.setBody({
"status": "error",
"message": "Failed to create record producer"
});
}
})(request, response);
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2024 05:27 AM - edited 05-18-2024 05:39 AM
@Sohail Khilji Let me test it and I will share an update on this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2024 06:13 AM
@Sohail Khilji if I add the record Item table, a new record item is getting inserted in the catalog items but not the record it self.
Is there any way to target the item with sys_id like the OOB API instead of table gliderecord? Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2024 12:40 AM
Have you considered using the OOB Record Producer REST API?