When you encounter an error message stating that a function convertUTCtoTimezoneMS cannot be found within a specific object, but the script you provided doesn't reference that function directly, there are a couple of scenarios and corresponding solutions to consider. Since you mention that the script works in another instance but not in the current one, the issue might stem from environment-specific configurations or customizations.
Here’s a systematic approach to troubleshoot and potentially resolve your issue:
1. Check for Custom Definitions
The convertUTCtoTimezoneMS function isn’t a standard ServiceNow API, suggesting it might be defined in a Script Include, a UI Script, or another custom script source in the instance where it works.
-
Review Custom Script Includes: Look for any custom Script Includes in the working instance that might define convertUTCtoTimezoneMS. If you find such a Script Include, ensure it's also present and active in the instance where you're encountering the error.
-
Check Other Customizations: Sometimes functions are defined within UI Scripts or even within specific client scripts or business rules. Ensure that all relevant custom scripts are present and properly deployed in the non-working instance.
2. Verify Global Access
If the function is defined in a Script Include, ensure the Script Include’s "Accessible from" setting is appropriate for where you're trying to call it. If a function needs to be accessible from both client and server scripts, the Script Include should be marked as "Client Callable."
3. Confirm Application Scope
If you are operating in different scopes between instances (e.g., moving from a global scope to a scoped application), there might be accessibility issues. Make sure that the script or resource defining convertUTCtoTimezoneMS is accessible within the scope of your current script.
4. Synchronize Instances
It’s possible that the environment where the script works has received updates or customizations not yet applied to the instance throwing the error. Ensure both instances are synchronized in terms of custom scripts, updates, and Scope applications.
5. Look for Missing Plugins or Dependencies
The function in question might be part of a plugin or an external library that is activated in one instance but not the other. Compare the list of installed plugins and custom libraries between the two instances.
6. Debugging Step
Since the error pertains to a function not directly referenced in the provided script, it might be called elsewhere in the workflow. Check other script steps in your workflow or any script that could be indirectly invoked, like through a Business Rule or a server-side script include called within the workflow context.
If this systematic review doesn’t resolve the issue, consider the following steps specific to debugging in ServiceNow:
-
Use the Script Debugger: For server-side scripts, ServiceNow's Script Debugger can help step through the code to see where it might be indirectly calling the undefined function.
-
Review Logs: Check the system logs for any related errors or warnings that might provide more context on where convertUTCtoTimezoneMS is invoked.
-
Replicate Custom Functionality: If for any reason, you cannot find the original definition of convertUTCtoTimezoneMS, you may need to replicate its functionality based on what it's supposed to do (e.g., converting UTC time to a specific timezone). ServiceNow’s GlideDateTime API offers methods for dealing with time zones that might serve as a basis for rewriting the missing function.
Final Note
If the function is crucial for your workflow and no direct replacement or built-in function exists, consider reaching out to ServiceNow’s community or your instance’s support channel for more specific guidance, especially if this involves custom-built functionality unique to your organizational processes.