copy content of date/time type onto another field.

SNnewbie2
Tera Expert

I want to get the content of my date and display it in another field or checkbox.

Capture.PNG

4 REPLIES 4

vab_13
ServiceNow Employee
ServiceNow Employee

var stringDateTime = dateTimeField.toString();


var integerEpoch = new Packages.org.apache.poi.hpsf.Util.filetimeToDate(stringDateTime);



And then do your calculations as required.




I tested this just now:


========


var myDate = gs.nowDateTime();
var gdt = new GlideDateTime(myDate);
var epoch = gdt.getNumericValue();
gs.print(myDate);
gs.print(epoch);
gs.print(gdt.getValue());




OUTPUT =>
*** Script: 08-23-2017 16:47:27
*** Script: 1503506847000
*** Script: 2017-08-23 16:47:27

========




Mark your feedback( Like or Helpful or Correct) as per the impact of my response. Cheers!


Vab


I don't this that is a solution for my question.This i a catalog item. I want the text to be You have selected a date that is beyond 72 hours, this work won't be completed until 2017-09-07 16:36:16".


Dennis R
Tera Guru

Hey Claudia, a couple of questions. I'm assuming this is on a form, such as a change request record or a request item record. Just to make sure, this isn't a catalog item, is it?



Second, and more importantly, I'm a bit confused about what exactly you're trying to accomplish. Do you want the text to actually be appended to the label of the checkbox field? Like, do you want the label to change to something like, "You have selected a date that is beyond 72 hours, this work won't be completed until 2017-09-07 16:36:16"?



If so, have you considered using a client script with showFieldMsg instead? That would probably be a bit more visible and informative for the end users, and is a lot better supported.


This i a catalog item. I want the text to be You have selected a date that is beyond 72 hours, this work won't be completed until 2017-09-07 16:36:16".


I am not familiar with showFieldMsg, do you know how to use that?