
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2019 07:59 AM
Hi all,
I'm trying to set up a scheduled job that runs off a variable on the sc_item_option table called 'Termination Date'.
The problem I have is that the value in the sc_item_option table has converted the value to a string, therefore when i try to put a query on date, it isn't recognizing the value as a date.
Is it possible to store this value as a date so we can query on it..?
Thanks guys
Rich
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2019 01:56 AM
Hi,
How about querrying sc_req_item itself, sample code would be below
var gr = new GlideRecord("sc_req_item");
gr.addActiveQuery();
// Use can add more filter condition here to filter the number of records
gr.query();
while (gr.next()) {
var vars = gr.variables;
for ( var v in gr.varibles ) {
if ( v == "giveTheNameOfTheVariableHere") {
var dateTime = new GlideDateTime(gr.variables[v].toString());
// Write your logic here based on your calculations, now you have DateTime Object access via variable dateTime
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2019 08:15 AM
Hi there,
The value field on the sc_item_option table and also question_answer table are just String fields. No such thing as storing it as a date, etc..
So you would have to script this (if it's a scripted query?), and in your code transform the string to a date. Or are you talking about a manual query on the List for example.
Kind regards,
Mark
---
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2019 08:32 AM
Hi Mark,
Thanks for your reply - it's a scripted scheduled job querying the sc_item_option table so I gather that means we'd have to script it.
In theory, could you add a date field to the sc_item_option table? or is that just not possible?
Thanks for your help
Richard

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2019 08:39 AM
Well if it's scripted, you could use the Glide Date: https://developer.servicenow.com/app.do#!/api_doc?v=kingston&id=r_ScopedGlideDateGlideDate
Adding a field to the sc_item_option with what purpose? To have a business rule for example that fills the custom date field if the type of the variable == date?
Could be an option depending on your needs. I personally would not go for this, if it's just for this scripted, you could script this fairly easily.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
---
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2019 01:42 AM
Hi Mark,
We are trying to pick up expired termination dates so I'm not sure if we could apply that - my level of coding is low so I'm pretty much open to suggestion at the moment!
Thanks for your time
Rich