Button is throwing an error in ATF : Change Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi all,
I am creating ATF for change management for custom use cases when i am clicking an Request Approval button it is giving me an error after clicking the button. attaching screenshot for reference.
any solution ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @Devansh00 ,
In your ATF script , somewhere you have used replace() function which is not supported by Servicenow.
The error "Cannot read properties of null (reading 'replace')" occurs when your ServiceNow client-side code executes a .replace() string function on a variable or field that contains no data or evaluates to null
For example:
var value = null;
var result = value.replace("old", "new");
Change the replace() by some supported function .
You ca share the code snippet as well .
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @Devansh00
Open Click a UI action step.
Set asset type as None.
***********************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful." This action benefits both the community and me.
***********************************************************************************************************************
Regards
Shaqeel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hey @Devansh00,
That failure is a client-side JavaScript error coming from the onclick script (or a client script tied to it) behind your Request Approval button, not an ATF platform bug: something in that script is calling .replace() on a field value that's coming back null for your test record. Your log only shows assignment_group getting set before the click, so odds are the script reads another field, justification, business justification, whatever your custom logic checks, that never got populated by the test and blows up when it tries .replace() on it.
- Log in as the ATF test user and click the button manually with the browser console open, that gives you the exact line and script throwing the error
- Open that UI Action's onclick script and any related client scripts, search for .replace(
- Either add the missing field to your ATF "Set Field Values" step, or fix the script to null-check before calling .replace()
- If none of that applies, repair the com.glide.automated_testing_framework and com.snc.change_management.atf plugins and retest in an incognito window, some orgs see this after an upgrade
Thank you,
Vikram Karety
Octigo Solutions INC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago