This site has been archived. Please visit help.fulcrumapp.com for our new support documentation and contact information.

Calculation Fields - Manipulating a Comma Delimited Text String (An Array?)

Adam C's Avatar

Adam C

22 Oct, 2016 02:00 PM

Hoping someone can provide some insight on a problem that I'm having (using my limited JavaScript knowledge). I've been poking around the documentation and I can't seem to find a function that will return a specific value in an array by it's location in the array. Normally in Javascript, I'd use the slice function, but doesn't seem to be working for me in Fulcrum.

Here is what I'm trying to do:

$variable contains the following text: AA,BB,CC,DD,EE,FF,GG

I'm trying to use a calculation field to return the text located at position 1 (BB) of $variable.

Any ideas how to do this?

  1. 1 Posted by Adam C on 22 Oct, 2016 02:06 PM

    Adam C's Avatar

    For clarification, $variable contains a text string of comma delimited text values which can vary in length. i.e. AAA,BBBB,C,DDDDD,EE,FFFFFFFFF,GG,HH

  2. 2 Posted by Bryan McBride on 22 Oct, 2016 02:16 PM

    Bryan McBride's Avatar

    Is $variable a string or array? Is it a text field or something like a choice list.

  3. 3 Posted by Adam C on 22 Oct, 2016 02:54 PM

    Adam C's Avatar

    $variable is a string (it is a text field).

  4. 4 Posted by Bryan McBride on 22 Oct, 2016 04:00 PM

    Bryan McBride's Avatar

    You should be able to turn the string into an array and then grab the value at your position, like so:

    var arr = $variable.split(',');
    SETRESULT(arr[1]);
    
  5. 5 Posted by Adam C on 23 Oct, 2016 11:20 PM

    Adam C's Avatar

    This worked! Thanks for your help, Bryan.

  6. Alex Helms closed this discussion on 24 Oct, 2016 01:14 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac