Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

GREP PROBLEM? Attribute parts of one fields rawvalue to other fileds

Avatar

Former Community Member

I am trying to find a way to divide the rawvalue of an input field into its component words

so if field A has a vlaue of "Julia Alison Child"

i would like to be able to cut that up into Firstname Middlename and Lastname fileds

I susepct it can be done using grep by determining when the first and second spaces occur

and taking everything before that for field onei.e Firstname

everything after that and before the second for Middlename and everythign after the second space for Lastname.

Conseptually it's simpe enough but I cant scavange a workign code sample and my coding isnt up to the job

....

anyone seen anythign like this before?

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

try this method.

var Input = Textfield1.rawValue;

var NameParts = Input.split("\u0020");

if (NameParts.length === 1)

{

FirstName.rawValue = NameParts.slice(0,1).toString();

MiddleName.rawValue = "";

LastName.rawValue = "";

}

if (NameParts.length === 2)

{

FirstName.rawValue = NameParts.slice(0,1).toString();

MiddleName.rawValue = "";

LastName.rawValue = NameParts.slice(1,2).toString();

}

if (NameParts.length === 3)

{

FirstName.rawValue = NameParts.slice(0,1).toString();

MiddleName.rawValue = NameParts.slice(1,2).toString();

LastName.rawValue = NameParts.slice(2,3).toString();

}

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

Hi,

try this method.

var Input = Textfield1.rawValue;

var NameParts = Input.split("\u0020");

if (NameParts.length === 1)

{

FirstName.rawValue = NameParts.slice(0,1).toString();

MiddleName.rawValue = "";

LastName.rawValue = "";

}

if (NameParts.length === 2)

{

FirstName.rawValue = NameParts.slice(0,1).toString();

MiddleName.rawValue = "";

LastName.rawValue = NameParts.slice(1,2).toString();

}

if (NameParts.length === 3)

{

FirstName.rawValue = NameParts.slice(0,1).toString();

MiddleName.rawValue = NameParts.slice(1,2).toString();

LastName.rawValue = NameParts.slice(2,3).toString();

}

Avatar

Former Community Member

Hi Radzmar - thanks for the code - perfect.........