Is it possible to change a currency symbol in a e....
# suitescript
k
Is it possible to change a currency symbol in a e.message? It's now in Dollar($) and want to change it to EUR(€)
Line item sum of $2,264.6 does not equal amount of $2,264.61
m
e.message meaning a try/catch block's error message? Presumably you could just use basic JS to do a string replace -
e.message.replace('$', '€')
k
yes try/catch/finally tried the replace also in combination with toString
👍 1
Copy code
catch (e) {
                  log.error({title: 'Error', details: 'In error' + e});
                  record.submitFields({type: record.Type.RETURN_AUTHORIZATION, id: currRecord.id, values: {'custbody_bf_rma_failed_to_process': e.message.toString().replace('$', '€')}});
@mrob do you have any idea what could fix this?(does not work with both options)
m
Oh sorry I thought it was working with
e.message.toString().replace('$', '€')
, what error do you get?
k
The Line item sum you see above with the dollar amounts and this should be EUR
m
even with
.replace('$', '€')
it's not changing the currency symbol in that record?
k
Nope, that’s the weird thing. No changes at all
m
hm i'm not sure without seeing more of your code, the javascript replace is pretty basic and works in console
Oh replace only replaces the first sorry needs to be regex
or just replaceAll
k
Copy code
try {
                  var cmRecordId = cmRecord.save({
                     enableSourcing: true,
                     ignoreMandatoryFields: false
                  });

                  log.debug({title: 'Success', details: 'Credit Memo ID: ' + cmRecordId});
                  record.submitFields({type: record.Type.RETURN_AUTHORIZATION, id: currRecord.id, values: {'custbody_bf_cm_processed': true}});
//                  checkRefund(cmRecord);
               } catch (e) {
                  log.error({title: 'Error', details: 'In error' + e});
                  record.submitFields({type: record.Type.RETURN_AUTHORIZATION, id: currRecord.id, values: {'custbody_bf_rma_failed_to_process': e.message.replaceAll('$', '€')}});
               } finally {
                  return true;
unfortunately not...
m
Oh that looks like a different error? Transaction is not in balance I don't think is related to the error message logging? And the screenshot you shared if from the actual system log, which would not be related to your record.submitFields line
k
it's pushing that same error message in the submitFields line
m
I'm not sure sorry Kevin, maybe e.message isn't what you think it is?