- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2014 02:54 PM
I have created a custom table and am attempting to use it on an Inbound Email Action. I have run into a problem however in using GlideRecord to query the table. What is happening is that I will issue a Query and get the expected number of rows back as seen by .getRowCount(). I can issue a .next() to the query and access the first record returned without issue. However from this point on it does not believe there are any more records. If I run .hasNext() it returns false and if I try to use .nex() nothing changes.
This is my first foray into custom tables so I'm not sure if I missed some specific field needed to allow queries to properly work. The table does not extend anything and has one reference. Other than that it has the default values, 2 choice lists and the rest are strings. If I change the sorting parameters I can alter which record is first without issue and using the same code I can put in an existing table and navigate the records without issue. The table is extensible right now and autonumbered.
Any help would be greatly appreciated. Here is the code I'm using, ignore that it is using a count instead of having .next() in the while loop, it is setup this way from debugging this issue.
var lookup = new GlideRecord('u_failed_event_rules'); lookup.query(); var count = lookup.getRowCount(); logger.logInfo('row count ' + count) while (i < count){ logger.logInfo('has next ' + lookup.hasNext()); lookup.next(); logger.logInfo('query details ' + ' policy ' + lookup.u_policy.toString() + ' client ' + lookup.u_client + ' label ' + lookup.u_schedule_label + ' type ' + lookup.u_schedule_type); }
In the logging you can see this from the logger statements( note that the 3 query details should all be different):
row count 3
has next true
has next false
has next false
query details policy SQL_NJTOSQLC03_Daily client njtosqlc03 label TEST2 type FULL
query details policy SQL_NJTOSQLC03_Daily client njtosqlc03 label TEST2 type FULL
query details policy SQL_NJTOSQLC03_Daily client njtosqlc03 label TEST2 type FULL
Solved! Go to Solution.
- Labels:
-
Service Mapping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2014 07:19 AM
I was able to solve it, the solution makes absolutely no sense to me but it is working.
All I did was change my variable for the query from 'lookup' to 'gr' and now it works. No logic changes at all were made.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2014 02:55 PM
sorry accidentally cut out the i++ when removing comments. That is in there.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2014 03:32 PM
Try using the following code:
var lookup = new GlideRecord('u_failed_event_rules');
lookup.query();
while (lookup.next()){
logger.logInfo('query details ' + ' policy ' + lookup.u_policy.toString() + ' client ' + lookup.u_client + ' label ' + lookup.u_schedule_label + ' type ' + lookup.u_schedule_type);
}
Does that give you the proper results? Just wanted to keep it real simple. It's difficult to troubleshoot an issue when you do not have the exact code in front of you. Is there any other code that may be affecting your script?
You do not have to do anything special for a custom table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2014 03:37 PM
That is how I had it originally. I changed it for some testing. Neither way works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2014 04:18 PM
What happens when you run that bit of code as a Background Script? You have to be careful when running Background Scripts, but this should be fine.
If you still get unexpected results, I'd probably clear the cache. This is Dev, right? Type "cache.do" in the navigator filter, let it do it's thing then rerun the code.