Split and/or Trim

SOLVED

var str = ${n}; var res = str.split(" "); return res[0]

I think I was mixing up the formatting from storeEval and also did’t understand where to put the return function.

OP
I have been trying for quite some time to make this work. Your help is appreciated.

If I have a name, like Erock Boulder, it would be stored as ${fn}. What am I missing in my second command?

I’ve also run into the issue of using trim() and while I didn’t get an error, I end up with the same value…

“Command”: “storeText”,
“Target”: “xpath=//*[@id=“jfInbox”]/div/div[3]/div/div[2]/div/div[2]/div/div[2]/div/div[2]/div/div[1]/div/div[2]/div”,
“Value”: “fn”
},
{
“Command”: “executeScript_Sandbox”,
“Target”: “return ${fn}.split(\” \")[0].trim()",
“Value”: “j”

Split code working like a charm tested !

{
  "Name": "Split_Function",
  "CreationDate": "2019-10-26",
  "Commands": [
    {
      "Command": "store",
      "Target": "11111-22222",
      "Value": "Col"
    },
    {
      "Command": "executeScript_Sandbox",
      "Target": "return ${Col}.split(\"-\")[0].trim();",
      "Value": "First_Part"
    },
    {
      "Command": "echo",
      "Target": "${First_Part}",
      "Value": ""
    },
    {
      "Command": "executeScript_Sandbox",
      "Target": "return ${Col}.split(\"-\")[1].trim();",
      "Value": "Second_Part"
    },
    {
      "Command": "echo",
      "Target": "${Second_Part}",
      "Value": ""
    }
  ]
}