Import data into Duration type field

chandanveeranna
Tera Contributor

Hi SNians,

I am working on a Custom table that i have created and wanted to *IMPORT DATA INTO THE DURATION FIELD* 

AFAIK Servicenow accepts values in milliseconds. I have duration in excel ranging from 15 mins to 20 days. Understanding this i converted the duration in excel into seconds and wrote a single line code in the transform script

 

ie "target.duration.setDateNumericValue(*1000);"

 

I mapped the fields accordingly and ran the transform. For my surprise the all records were empty except 15mins. 

 

I am really not sure where exactly i need to change to get this working. It is quite critical and needs to be moved quickly. I appreciate all you help.

 

 

1 ACCEPTED SOLUTION

Archana Reddy2
Tera Guru

Hi Chandhan,

The below link may help you.

https://community.servicenow.com/community?id=community_question&sys_id=594ffa69db58dbc01dcaf3231f961928

 

Thanks

View solution in original post

5 REPLIES 5

Jaspal Singh
Mega Patron
Mega Patron

Hi Chandan,

 

Can you try using one liner code as below

 

target.duration.setDateNumericValue(source.u_duration*1000); //Transforms the value in source.u_duration from seconds to milliseconds

 

Thanks,

Jaspal Singh

 

Hit Helpful or Correct on the impact of response.

Archana Reddy2
Tera Guru

Hi Chandhan,

The below link may help you.

https://community.servicenow.com/community?id=community_question&sys_id=594ffa69db58dbc01dcaf3231f961928

 

Thanks

Thanks Archana and Jaspal.. it worked after ,making the code change as

ie "target.u_duration.setDateNumericValue(u_duration*1000);"

Glad you achieved that.

Please close this thread by marking the helped answer as correct.

Thanks