How to fetch list of records from database table with a query string containing special charachters and spaces?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2014 12:07 PM
i have a data base field named as "short_description" in a table customer . I want to fetch list of records from the table with a query string like this;
var gr = new GlideRecord('customer');
gr.addQuery('short_description','abc , cfg rth_as@abc.com');
gr.query();
while(gr.next())
{
/* some actions performed */
}
-------------------------------------------------
the query does not fetch any records from the table customer............... is there any other way to query with that particular string value to fetch data with exact matches?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2014 12:22 PM
I don't think you can possibly have a string field with that name, precisely because field names can't have special characters and spaces in them. If you try to create a field with a name like that above, SNC will substitute all the spaces and special characters with the underscore, resulting in the field name: "u_abc__efg_ius___poc".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2014 07:50 AM
Geoff Cox please check my post which i have updated above for your reference.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2014 07:33 AM
So I went on the demo site and tried the following with no problem. I added a field "u_test_field_gbc" to the change_task table. I put the value "abc, cfg rth_as@abc.com" in the field. Then I wrote the following scheduled job:
do_run_test_script();
function do_run_test_script() {
var task = new GlideRecord('change_task');
task.addQuery('u_test_field_gbc','abc , cfg rth_as@abc.com');
task.query();
while (task.next()) {
gs.log('GBC - test query - found task ' + task.getDisplayValue() + ' with test value [' + task.u_test_field_gbc + '].');
}
}
The system log contained the single entry: GBC - test query - found task CTASK0010001 with test value [abc , cfg rth_as@abc.com].
Is that what you're looking for?
Cheers,
Geofff.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2014 08:56 AM
I could see that there is some syntax problem. Kindly check whether the table name is "u_customer" instead of "customer".
Second thing, please refer the link for string related query - http://wiki.servicenow.com/index.php?title=Using_GlideRecord_to_Query_Tables#Available_JavaScript_Op...
I hope this helps.