- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2024 06:49 AM
Hi All,
We have field on our custom table where we store comma separated values in string type field.
We have a inbound action email script but not working.
Let me know how can we achieve this?
Thank you in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2024 07:21 AM
hi @Ssinha4
To check for comma-separated field values in a GlideRecord query, you need to properly parse the values from the field and compare them against your criteria. Check bellow script once and let me know its working or not:
var gr = new GlideRecord('your_custom_table'); // Replace with your actual table name
gr.addEncodedQuery('u_recipient=' + recipient);
gr.addNotNullQuery('u_vendor');
gr.query();
while (gr.next()) {
var vendors = gr.u_vendor;
if (vendors) {
// Split the vendors into an array
var vendorArray = vendors.split(',');
// Trim whitespace and check if the sender is in the vendor array
for (var i = 0; i < vendorArray.length; i++) {
if (vendorArray[i].trim() === sender) {
// Match found - remaining code here
gs.info('Match found for sender: ' + sender + ' in vendors for record: ' + gr.sys_id);
// Add your additional logic here
break; // Exit loop if match is found
}
}
}
}
i hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.
thank you
rajesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2024 07:21 AM
hi @Ssinha4
To check for comma-separated field values in a GlideRecord query, you need to properly parse the values from the field and compare them against your criteria. Check bellow script once and let me know its working or not:
var gr = new GlideRecord('your_custom_table'); // Replace with your actual table name
gr.addEncodedQuery('u_recipient=' + recipient);
gr.addNotNullQuery('u_vendor');
gr.query();
while (gr.next()) {
var vendors = gr.u_vendor;
if (vendors) {
// Split the vendors into an array
var vendorArray = vendors.split(',');
// Trim whitespace and check if the sender is in the vendor array
for (var i = 0; i < vendorArray.length; i++) {
if (vendorArray[i].trim() === sender) {
// Match found - remaining code here
gs.info('Match found for sender: ' + sender + ' in vendors for record: ' + gr.sys_id);
// Add your additional logic here
break; // Exit loop if match is found
}
}
}
}
i hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.
thank you
rajesh