Button is throwing an error in ATF : Change Management

Devansh00
Tera Contributor

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 ?

 

Devansh00_0-1784050530057.png

 

4 REPLIES 4

Tanushree Maiti
Tera Patron

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 .

 

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

Shaqeel
Mega Sage

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

Vikram Reddy
Tera Guru

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

Hi @Vikram Reddy 

 

 
"I haven't used any script anywhere, and this button is working perfectly fine in Workspace. The issue is occurring only in the Native UI."