How to get account expires field form AD to user table.

Alex_3
Tera Contributor

Hello All,

I am unable to resolve this since few days,

I want to calculate when an users account will expires, Coming from AD.

I want a script to calculate when users account will expire and Map it in sys_user table field 'u_acc_expire'.

 

need some assistance.

Thanks!!

3 REPLIES 3

Swapna Abburi
Mega Sage
Mega Sage

@Alex_3 

Are you trying to fetch Expiry date from Active directory and update a field in user account in ServiceNow? If yes, please provide the format of expiry date from AD?

Hello @Swapna Abburi 

Thanks for your response.

Yes I am trying to fetch AccountExpires Date from AD to sys_user table field which is in Date/time 'account expires'

 

Regards,

Ruchi

Swapna Abburi
Mega Sage
Mega Sage

@Alex_3 

If the date and time format from AD is ""202212072308Z", then you may use below script to in transform field map source script.

var s = source.<field_name>;
var dt = s.substring(0,4)+'-'+s.substring(4,6)+'-'+s.substring(6,8)+' '+s.substring(8,10)+':'+s.substring(10,12);

return new GlideDateTime(dt);