Scenario:
When we try to pass the parameters through url, but unable to get values from the parameters.
var reportURL = url.resolveScript({
scriptId: ‘customscript_jj_sl_cpe_dashboard’,
deploymentId: ‘customdeploy_jj_sl_cpe_dashboard’,
params: {
‘buff_filters’: buff_filters,
‘otherFilters’: otherFilters,
‘bill_filters’: bill_filters
},
returnExternalUrl: true
});
var buff_filters = scriptContext.request.parameters.buff_filters; is not working where buff_filters=[[“custrecord_jj_cpebuff_billtype”,”is”,”Buffer”]]
Solution:
The issue might be related to how the parameter buff_filters is being encoded or parsed in the URL.
it might be because buff_filters contains special characters or complex structures that are not being properly encoded.
To troubleshoot this, you can:
- Encode the parameters before passing them in the URL.
- Log the URL to check if the parameters are being included correctly.
- Check the received request parameters to see if they match what was sent.
// Encode the parameters before passing them in the URL
var encodedBuffFilters = encodeURIComponent(JSON.stringify(buff_filters));
var encodedOtherFilters = encodeURIComponent(JSON.stringify(otherFilters));
var encodedBillFilters = encodeURIComponent(JSON.stringify(bill_filters));
var reportURL = url.resolveScript({
scriptId: ‘customscript_jj_sl_cpe_dashboard’,
deploymentId: ‘customdeploy_jj_sl_cpe_dashboard’,
params: {
‘buff_filters’: encodedBuffFilters,
‘otherFilters’: encodedOtherFilters,
‘bill_filters’: encodedBillFilters
},
returnExternalUrl: true
});
On the receiving end, make sure you decode the parameters and parse them correctly:
function getDecodedParam(param) {
return param ? JSON.parse(decodeURIComponent(param)) : null;
}
// In your SuiteScript handler
var buff_filters = getDecodedParam(scriptContext.request.parameters.buff_filters);
var otherFilters = getDecodedParam(scriptContext.request.parameters.otherFilters);
var bill_filters = getDecodedParam(scriptContext.request.parameters.bill_filters);