Skip to main content



String Functions

Get List Item By Index

Returns the selected item from a comma separated list of text. Indexing is zero-based indexing, so passing in "4" returns the fifth word from the list.

Parameters

  • list (Text)
  • index (integer)

Return Type

Text

Script

var values = list.Split(",");
if(index < values.Length)
{
return values[index];
}
return "";

Get List Item Count

Returns the count of items from a comma separated list of text.

Parameters

  • list (Text)

Return Type

integer

Script

var values = list.Split(",");
return values.Length;

Get Text After

Returns the text after the first found match for the supplied match text.

Example:

GetTextAfter("abc", "this abc word is the second word"); // returns "word is the second word"

Parameters

  • findText (Text)
  • text (Text)

Return Type

Text

Script

if(text == null)
return "";
var startIdx = text.IndexOf(findText);
var s = "";
if (startIdx > -1)
{
s = text.Substring(startIdx + findText.Length)
}
return s;

Get Text Before

Returns the text before the first found match for the supplied match text. Example:

GetTextBefore("abc", "this is the abc text"); // returns "this is the"

Parameters

  • findText (Text)
  • text (Text)

Return Type

Text

Script

 if(text == null)
return "";
var startIdx = text.IndexOf(findText);
var s = "";
if (startIdx > -1)
{
s = text.Substring(0, startIdx)
}
return s;

Get Text Between

Returns the text between the supplied start and end text.

Example:

GetTextBetween("FirstName", "LastName", "FirstName MiddleName LastName"); // returns "MiddleName"

Parameters

  • findStartText (Text)
  • findEndText (Text)
  • text (Text)

Return Type

Text

Script

 if(text == null)
return "";
var startIdx = text.IndexOf(findStartText);
var s = "";
if (startIdx > -1)
{
var endIdx = text.Substring(startIdx + findStartText.Length).IndexOf(findEndText);
if (endIdx > -1)
{
s = text.Substring(startIdx + findStartText.Length, endIdx);
}
}
return s;

Get Text Between Inclusive

Returns the text between the supplied start and end text, including the start and end text. Example:

GetTextBetweenInclusive("FirstName", "LastName", "FirstName MiddleName LastName"); // returns "FirstName MiddleName LastName"

Parameters

  • findStartText (Text)
  • findEndText (Text)
  • text (Text)

Return Type

Text

Script

 if(text == null)
return "";

var startIdx = text.IndexOf(findStartText);
var s = "";
if (startIdx > -1)
{
var endIdx = text.Substring(startIdx + findStartText.Length).IndexOf(findEndText);
if (endIdx > -1)
{
s = text.Substring(startIdx, findStartText.Length + endIdx + findEndText.Length);
}
}
return s;

Is Found In List

Looks for text in a comma separated list of values and returns TRUE if found and FALSE if not found.

Parameters

  • text (Text)
  • list (Text)

Return Type

Boolean

Script

 if(list == null)
return false;
var values = list.Split(",");
var isMatch = false;

for(var val in values)
{
if(val == text)
{
isMatch=true;
break;
}
}
return isMatch;

Parse Date String

Returns a DateTime from a string that can be resolved to a date.

Parameters

  • dateString (Text)

Return Type DateTime

Script

 try
{
return Util.DateTime.Parse(dateString);
}
catch(error)
{
}
return "";

Strip Leading Text

Returns the supplied text with the supplied leading text removed. Example:

StripLeadingText("abc", "this is abc, but this is not");
// returns ", but this is not"

Parameters

  • findText (Text)
  • text (Text)

Return Type

Text

Script

 if(text == null)
return "";
if(text.StartsWith(findText))
{
return GetTextAfter(findText, text);
}
else
{
return text;
}

Load XML To Entity

Loads the supplied XML into the current entity.

Example:

LoadXmlToEntity(`"<TextField1>This is Field 1 data</TextField1><TextField3>This is Field 3 data</TextField3>"`); loads "This is Field 1 data" into TextField1 and "This is Field 3 data" into TextField3.

Parameters

  • xml (Text)

Return Type

None

Script

 var entity = Context.Entity;
for (var i = 0; i < entity.Fields.Count; i++)
{
var fieldName = entity.Fields[i].Name;
var value = GetTextBetween("<" + fieldName + ">", "</" + fieldName + ">", xml);
if (Util.String.IsNullOrEmpty(value) == false)
{
entity.Fields[i].SetValue(value);
}
}

Count Words

Returns the count of the instances of a given word, e.g. "abc" in a supplied text block.

Parameters

  • text (Text)
  • word (Text)

Return Type

integer

Script

var count = (text.Length - text.Replace(word, "").Length) / word.Length; 
return count;

Do Strings Match

Determines if supplied strings match based on the supplied Boolean "CaseInsensitive" parameter. If the strings match, it returns TRUE, otherwise FALSE.

Parameters

  • compareText1 (Text)
  • compareText2 (Text)
  • caseInsensitive (Boolean)

Return Type

Boolean

Script

return Util.String.Compare(compareText1, compareText2, caseInsensitive) == 0;