Left Function in Template

  • 1
  • Question
  • Updated 5 years ago
  • Answered
Is there a Left Function equivalent for a template box?  I only want to show the first 20 characters of a certain field while including additional characters from other fields.
Photo of Scott


  • 2,732 Points 2k badge 2x thumb

Posted 5 years ago

  • 1
Photo of Pat Vachon

Pat Vachon, Champion

  • 44,426 Points 20k badge 2x thumb
I don't think there is. I've looked for this as well and could not find anything functions other than the # truthy or ^ falsy.
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,828 Points 20k badge 2x thumb
Can do this in a template field, but you can do this as a custom renderer in Javascript.  Here is a social security masking snippett.  You can probably repurpose.  
The field where you will show this data should use renderer type "custom"   The name should be the same as that you give the snippet. 
The snippet should be of type "In-Line Snippet" 

Here is the code: 

// Only use the last four digits of a string  (Like a SSN)
var field = arguments[0];
var value = arguments[1];
var minValue = value.substr(value.length - 4);
var text = "***-**-"+minValue;
skuid.ui.fieldRenderers.TEXT[field.mode](field, text);