Understanding sn_sc.CartJS() in ServiceNow: Its Importance and Use Cases
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi,
I have added a 'Joining Date' variable of type Date. However, when users upload details with the Joining Date left blank, the system automatically populates it with the current date. I have not configured any default value or set it to the current date. Could you please help confirm whether this is the default behavior of the Chart.js API, or if there is any other configuration that might be causing this?"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
I would recommend checking the following:
. Catalog Client Scripts that may be setting the value on load or submit.
. UI Policies that could be modifying the field value.
. Record Producers or Flow Designer actions that populate the field when the request is submitted.
. Business Rules or Transform Maps (if data is being imported) that may be defaulting blank dates to the current date.
. Any integration or custom script that processes the variable after submission.
If you're referring to a Service Catalog variable, there is no out-of-the-box behavior that automatically sets an empty Date variable to today's date. Also, this behavior would not be related to the Chart.js API.
// WRONG (This causes the issue):
// If source.u_joining_date is blank, 'new GlideDateTime("")' or an unhandled string might fallback to the current date/time in some JavaScript environments.
current.joining_date = new GlideDateTime(source.u_joining_date);
// RIGHT (The Fix):
if (source.u_joining_date && source.u_joining_date != "") {
current.joining_date = source.u_joining_date;
} else {
current.joining_date = ""; // Explicitly keep it blank
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
@SnehaS895807473
as per the understanding when processing data uploads or catalog submissions through APIs, an empty date string "" or an unassigned property often breaks the backend date type formatting. To protect the database from generating a null value or crashing the transaction, the platform's Java engine or underlying data processors frequently fall back to today's current date automatically.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
34m ago
On your Joining date variable ,
- Right-click the field label and select Configure Dictionary.
- Navigate to the Default Value tab.
- In the Default Value text box - check what value has been set.
Generally we set following any of default value
If you keep the date variable's default value blank, and if you open catalog where that date variable is there,
you can see variable is showing blank.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti