Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to get only value of Time

Chronos
Tera Contributor

Hi,

I have 2 tables A and B.
In table A there is a field u_start_time: type Time in picture

Chronos_0-1709954543281.png

In table B I have a field with Reference type Name.
I used name.u_start_time to get data from table A. But there is no return value. I log in to get its information as shown below.

Chronos_1-1709954697636.png

Is there any way to get the correct value 01:00:00 from table A to table B?

Thank and Best Regards,

5 REPLIES 5

Anand Kumar P
Giga Patron

Hi @Chronos ,

You can create business rule use below script to and query table A  to get start time to TableB.

var grA = new GlideRecord('tableA');
grA.addQuery('query records as per your requirment');
grA.query();
while(grA.next()){
var grB = new GlideRecord('tableB');
grB.addQuery('name', grA.name);
grB.query();
if(grB.next()){
grB.u_start_time = grA.u_start_time.getDisplayValue();
grB.update();
}
}

 Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand

Hi, @Anand Kumar P 

My idea would be to set onChange for name, so when it changes the start time will also change accordingly. Perhaps the business rule is not appropriate here.

Hi @Chronos 
If you are trying On change client script , then on change of name you can call a script include to return the date from table A.
Have you tried this approach ? any blocker if you try this?

Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anwesha

Chronos
Tera Contributor

Hi @Anwesha3 

I tried but I had a problem returning the time value