Left Function in Template

  • 1
  • Question
  • Updated 4 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

Scott

  • 2,722 Points 2k badge 2x thumb

Posted 4 years ago

  • 1
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 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,006 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);