SuiteScript: How to Fix Ampersand (&) XML Parsing Error

by | Mar 8, 2023 | Development, Suite Guides

Here’s a quick tip for scripting, and possibly a quick resolution whenever you encounter an ampersand XML parsing error within SuiteScript.

We will use this email as an example when a script that had been running for many months without any issues. And basically, the main part of the error is here, error parsing XML, the incident name must immediately follow the ampersand in the entity reference.

And basically what this means is that somewhere in your script, there’s an ampersand that shouldn’t be there. Using the example, what happened was somebody introduced an ampersand (&) into someone’s job title which caused this XML parsing error to happen.

how to fix ampersand error parsing xml example

So there are two quick fixes for this ampersand XML parsing error:

  1. Either you can go into all the records that are referencing here in this script, and remove the ampersand or
  2. Fix the error using code.

Good to know: How long does it take to implement NetSuite?

If we go and look at the code basically, there is an XML.escape function within the code that will actually do the lookup on the field to enter the field. And so it knows what to do with the ampersand at that point in the XML. So that’ll actually come out and print the XML and the email. That’s what the script was doing, it’s actually sending the email out for payroll information. And that’s it.

Wrapping Up

As a highly accredited NetSuite Solution Provider, ScaleNorth is well positioned to help you with the full scope of your NetSuite customization needs. If you require more NetSuite assistance, contact ScaleNorth today.

About the Author

Chris Emory is a versatile and accomplished IT professional with 20 years of experience in information systems and functional consulting. Chris has a wealth of experience as a NetSuite Expert and holds the NetSuite Administrator and SuiteFoundation credentials.

By accessing and utilizing this Suite Guide, you acknowledge and agree that the information presented is for informational purposes only. Any actions taken based on the content are done so at your own risk. ScaleNorth, Inc. does not warrant this advice for accuracy. ScaleNorth Inc. is not liable for any disruptions, errors, or issues that may occur as a result of you or your team making self-imposed changes to your own NetSuite instance. When customizing NetSuite, it is recommended to utilize caution and to test your changes in a sandbox environment. Copying, downloading, embedding or distributing this content is forbidden unless explicitly authorized by ScaleNorth, Inc. For professional NetSuite consulting assistance, contact ScaleNorth.

Speak with one of our Netsuite Experts today.