We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Script Creating Change Record but then Record is not Found

fcaruso123
Tera Expert

I have a scripted web service used to create a change record. The script pulls values from JSON object and assigns to individual fields:

 

var grCHG = new GlideRecord('change_request');
grCHG.initialize();
grCHG.risk = dataJSON.risk;
grCHG.start_date = dataJSON.start_date;
grCHG.end_date = dataJSON.end_date;
grCHG.insert();

 

This is working correctly except when one of the date fields is sent with a bad date format. The insert() is running successfully, I am getting a change number returned, but when I go look for that change number it does not exist. No errors are getting thrown. I can do a GlideRecord lookup of the change number immediately after the insert() and it finds the change record. But when I go into the platform the change is record is not found. If I remove the dates from the insert the change is created and I can locate it in the platform. I looked in deleted records and its not there.
 
How does the change get created successfully but then cannot be found?
 
Thank you
Frank
 
 
 
 
5 REPLIES 5

Runjay Patel
Giga Sage

Hi @fcaruso123 ,

 

Whats the date format are you receiving? If you can share then i can give you the code.

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

Part 2. In this video i have talked about overview on ServiceNow platform/tool. How you can opt for personal dev instance (PDI)? how to login in ServiceNow instance and navigation to OOB modules. For document please visit: https://servicenowwithrunjay.com/ Follow Facebook page for latest update on