≡ Menu




split string in dynamics ax 2012

During one of customization scenario, I have come across to field which contains comma separated values. In C# and VB.net string.split method return into array of string. But in X++  split method return list. Following simple tip helps me to check that my required value exists in comma separated value.

public boolean getValidateStudentName(String50 _splitString)

{

 

List strlist=new List(Types::String);

ListIterator    iterator;

str _Value;

boolean _NotFound=boolean::true;

;

strlist=strSplit(_splitString,”,”);

iterator = new ListIterator(strlist);

while(iterator.more())

{

_Value =iterator.value();

if (_Value ==”Ali”)

{

_NotFound=boolean::false;

}

if (_Value ==”Raza”)

{

_NotFound=boolean::false;

}

if (_Value ==”Zaidi”)

{

_NotFound=boolean::false;

}

if (_Value ==”Lahore”)

{

_NotFound=boolean::false;

}

if (_Value ==”Pakistan”)

{

_NotFound=boolean::false;

}

iterator.next();

}

return _NotFound;

}

{ 0 comments… add one }

Leave a Comment