In NetSuite, the ‘encodeURIComponent' function is useful for encoding URL parameters to prevent errors caused by special characters. It is commonly used in SuiteScript when constructing URLs for redirects or API calls.
For example: The Encoded value of the given data is given below,
{
relatedProjects: [ "2709" ],
fields: {
custrecord_project_status: 10,
custrecord_project_parent_charity_status: "10"
},
newCharityStatus: "10",
PROJECT_COMPLETED: 6,
INELIGIBLE_CHARITY_STATUS: [ 9, 7, 8, 12 ],
SUSPENDED: [ 10 ]
}
encoded value: %7B%22relatedProjects%22%3A%5B%222709%22%5D%2C%22fields%22%3A%7B%22custrecord_project_status%22%3A10%2C%22custrecord_project_parent_charity_status%22%3A%2210%22%7D%2C%22newCharityStatus%22%3A%2210%22%2C%22PROJECT_COMPLETED%22%3A6%2C%22INELIGIBLE_CHARITY_STATUS%22%3A%5B9%2C7%2C8%2C12%5D%2C%22SUSPENDED%22%3A%5B10%5D%7D
This function helps maintain data integrity and ensures smooth URL handling in NetSuite scripts.