2

Can I change formatting of a Currency field using PowerShell

for example

in swedish regional setting currency field shows 100.000 kr (.dot as separator)

but I need to customize it's format to show as 100 000 kr (space as separator)

Can I do that? How to do that ?

3

You can achieve this requirement by using client side rendering(CSR) easily. Here 'Currency' is a currency type field.

(function () {
var overrideCurrentContext = {};
overrideCurrentContext.Templates = {};
overrideCurrentContext.Templates.Fields = {
    'Currency': { 'View': Currency }
};

SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCurrentContext);

function Currency(ctx) {
   var modifiedCurrency =ctx.CurrentItem.Currency.split(",").join(" ");
   return   modifiedCurrency
} 
})();

Before : enter image description here

After : enter image description here

Steps to add JS Link :

  • Save the below code to projectCode.js and upload to site assets of site collection/subsite
  • Go to the list view and go to the edit page by appending "toolpaneview=2".
  • Edit the webpart and open the 'miscellaneous' section. In the JSLink text box refer the JS file. If you have uploaded to the site collection's site assets, use ~sitecollection/siteassets/projectcode.js . If you have uploaded it to subsite's site assets use ~site/siteassets/projectcode.js
2
  • 1
    This should be enough to get the OP going, but I think you copy/pasted from a previous answer. You're replacing semi-colon with line breaks, instead of . with a space. – wjervis Aug 4 '17 at 12:29
  • Thanks @wjervis . After testing it out, pasted an old revision of the code which I started out with. Have fixed it now. – Priyaranjan KS Aug 4 '17 at 12:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.