Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dynamic Number formatter using script
#1
const kFormatter = (num) => {
  return Math.abs(num) > 999 ? Math.sign(num) * ((Math.abs(num) / 1000).toFixed(1)) + 'k' : Math.sign(num) * Math.abs(num)
}
var total_calls = changedItem.attributes.data[0].total_calls;
var call_length = total_calls.toString().length;
if(call_length>6){
        var total_calls = kFormatter(total_calls);
        sdk.setValue('label37',total_calls );
}
else
{
        sdk.setValue('label37',total_calls );
}
 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)