sc_item_option variable

Richard Thomas2
Tera Contributor

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'. 

find_real_file.png

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.

find_real_file.png

Is it possible to store this value as a date so we can query on it..?

Thanks guys

 

Rich

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION

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
            }
      }
}

View solution in original post

10 REPLIES 10

Mark Roethof
Tera Patron
Tera Patron

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

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Richard Thomas2
Tera Contributor

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 

 

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

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

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