@Lakshman 

Did you mistakenly mark other answer as correct?

As I could see the script shared by me worked well as per your previous comment.

Would you mind marking my response as helpful/correct if I was able to resolve your query?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader