How can we split the API Response into different attibutes?

0
How can I split the REST API response and display different parts in separate text boxes? Currently, the response is displayed in a single large text box, but I want to extract specific sections based on conditions. For example: UserStory1 should appear in Text Box 1 UserStory2 should appear in Text Box 2 And so on... Given the following example response:   Category: Infrastructure Priority: Medium Department: IT Support Issue Solution: Check for any hardware or software issues on the laptop. If the issue persists, try restarting the laptop or updating the drivers. If the issue still persists, escalate to the Dev Team for further investigation. How can I split and assign different parts of this response to individual text boxes in my Mendix application?
asked
1 answers
4

Hello Harish,

The challenge here is to split the string that comes from the response, and you can do it by using the StringSplit java action from the CommunityCommons module of Mendix. 

 

After getting the response, you need to use this Java action and with regex give the certain pattern for the string split. In the link below is the documentation where you can search for StringSplit.

https://docs.mendix.com/appstore/modules/community-commons-function-library/

 

Example

Suppose you have a string:

"apple;banana orange,grape"

 

And you want to split by comma, semicolon, or space.

Microflow Example:

  1. Create a microflow.
  2. Add a String variable:InputString = "apple;banana orange,grape"
  3. Call the StringSplit Java action from Community Commons:
    • String = $InputString
    • Separator (Regex) = [,; ]
  4. The result will be a List of Strings:apple, banana, orange, grape
  5. You can then loop through the list, store the parts, or use them as needed.

 

Let me know in case you need more info!

 

Kind regards!

Fjordi

answered