How to use String split function in Dynamics 365 for Operations:
How to get the string values one by one from a set of strings separated by comma in a textbox control.
Problem statement
Example: If string values are Apple, Orange, Banana, Grapes, etc.
Expected Output:
Apple
Orange
Banana
Grapes
Code snippet
List listFruitList = strSplit(SCCFruit.SCCFruitName, ‘,’);
ListEnumerator listFruitEnumerator = listFruitList.getEnumerator();
while(listFruitEnumerator.moveNext())
{
info(strFmt(“%1”,listFruitEnumerator.current()));
}
Short words about the resolution
The above code can be written in the button clicked() method or anywhere to be taken.
Detailed resolution steps of how to use String split function in Dynamics 365 for Operations
- Create a Table named SCCFruit with string field SCCFruitName
- Create a Form named SCCFrmFruit and add the datasource as SCCFruit
- In the design, right-click and select Custom
- Again, right-click and add a button and a group. In the group, drag and drop the field SCCFruitName.
- In the Submit button method, right-click and in override method select clicked
- Write the below code
List listFruitList = strSplit(SCCFruit.SCCFruitName, ',');
ListEnumerator listFruitEnumerator = listFruitList.getEnumerator();
while(listFruitEnumerator.moveNext())
{
info(strFmt("%1",listFruitEnumerator.current()));
}
- Create menu Item, Menu, and Main menu extension
- Below will be the output