- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2024 09:01 AM
Hi,
I have a below requirement
There is one custom table in which 2 fields are primary keys.
Item
Order Number
we are receiving data from another system.
for that we have been validating from my Scripted Rest resource as below
ar isExistingRecord = (function(order_no) {
var grTERD = new GlideRecord('my_custom_table');
grTERD.addQuery('order_no', order_no);
grTERD.query();
if (grTERD.next()) {
return true;
} else {
return false;
}
I am not checking Item and order number, I am only queriying on order number.
Can someone help me how to query order number and Item in a query.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2024 09:07 AM
Depending on the field name, you can add another addQuery which will look for a combination of both
ar isExistingRecord = (function(order_no,item) {
var grTERD = new GlideRecord('my_custom_table');
grTERD.addQuery('order_no', order_no);
grTERD.addQuery('item', item);
grTERD.query();
if (grTERD.next()) {
return true;
} else {
return false;
}
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2024 09:18 AM
Hello @Are Kaveri ,
Please give a try to the script below and let me know how it works for you.
var isExistingRecord = function(item, order_no) {
var grTERD = new GlideRecord('my_custom_table');
grTERD.addQuery('item', item); // Add query condition for the 'Item' field
grTERD.addQuery('order_no', order_no); // Add query condition for the 'Order Number' field
grTERD.query();
if (grTERD.next()) {
return true;
} else {
return false;
}
};
Let me know your views on this and Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks,
Aniket

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2024 09:07 AM
Depending on the field name, you can add another addQuery which will look for a combination of both
ar isExistingRecord = (function(order_no,item) {
var grTERD = new GlideRecord('my_custom_table');
grTERD.addQuery('order_no', order_no);
grTERD.addQuery('item', item);
grTERD.query();
if (grTERD.next()) {
return true;
} else {
return false;
}
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2024 09:14 AM
Hi @Are Kaveri ,
You can add item column in the addQuery() method and pass the value in function(order_no, item)
grTERD.addQuery('item', item);
-Thanks,
AshishKMishra
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2024 09:18 AM
Hello @Are Kaveri ,
Please give a try to the script below and let me know how it works for you.
var isExistingRecord = function(item, order_no) {
var grTERD = new GlideRecord('my_custom_table');
grTERD.addQuery('item', item); // Add query condition for the 'Item' field
grTERD.addQuery('order_no', order_no); // Add query condition for the 'Order Number' field
grTERD.query();
if (grTERD.next()) {
return true;
} else {
return false;
}
};
Let me know your views on this and Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks,
Aniket
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2024 09:21 AM
if it is a custom table mostly the fierld will start with u_
grTERD.addQuery('u_order_no', order_no);