cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Vstar19
Helper V
Helper V

Returning a single value from a String

Hi. I have a HTTP request which gets me some information in JSON format. 

I have added a For Each action which loops through the results and returns me the description section only of the HTTP Request. 

The description returned literally looks something like this 

 

First Name : John,
Last Name : Smith,
ID : 12345
Email : john.smith@domain.com,
Country : US

 

Now, i need the ID of that user. So it successfully returns the description. 

How can i get just the ID?

I tried body('Description')?['ID :'], but it returns an error saying it cant find ID. 

 

I believe the description is just a string that is returned. Is there a way i can write an expression to also return the ID from the description?

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Paulie78
Super User
Super User

You can use this expression:

trim(last(split(split(outputs('Compose'), decodeUriComponent('%0A'))[2], ':')))

You will need to modify it so outputs('Compose') is your string, example here:

2021-04-13_17-54-08.png

Output is: 12345

View solution in original post

5 REPLIES 5
CFernandes
Super User
Super User

@Vstar19 

 

You mentioned that "HTTP request which gets me some information in JSON format".

 

Why don't you use an Parse JSON action and extract the value.

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Vstar19
Helper V
Helper V

I tried the parse JSON, but it wouldn't work.

 

I was hoping I could write an expression to just extract the ID from the string.

Can you paste the output\response of the HTTP action?

Here is a sample. I have had to edit it slightly, so there may be some errors when you try to read it as JSON. 

 

{
"result":
{
"major_incident_state": "",
"u_requested_by_phone": "",
"universal_request": "",
"short_description": "Test",
"u_itil_watch_list": "",
"correlation_display": "",
"work_start": "",
"u_ca_reference": "",
"additional_assignee_list": "",
"notify": "2",
"service_offering": {
"link": "https://domain.com/",
"value": "290fg3bc2b1212209a18ef3e79da1582"
},
"sys_class_name": "sample",
"closed_by": "",
"sla_due": "",
"u_actual_response_date": "",
"u_sla_met": "Yes",
"opened_by": {
"link": "https://domain.com/"
},
"user_input": "",
"sys_created_on": "2021-04-06 11:41:10",
"sys_domain": {
"link": "hhttps://domain.com/",
"value": "global"
},
"proposed_on": "",
"actions_taken": "",
"u_quality_impact": "",,
"reopened_time": "",
"resolved_at": "",
"u_client": "",
"subcategory": "Test",
"work_notes": "",
"u_ah_incident": "",
"close_code": "",
"assignment_group": {
"link": "https://domain.com/",
"value": "e7662365db950c10b16cec01vb961231"
},
"business_stc": "",
"cause": "",
"description": "First Name : John,\r\nLast Name : Smith,\r\nID : 123456\r\nEmail : john.smithe@domain.com,\r\nCountry : US",
"u_planned_resolved_date": "",
"calendar_duration": "",
"category": "inquiry"
}

 

If you look at the above, in the description, there is a ID.. I need to be able to extract that ID. 

 

Hopefully that gives you an idea of what i am trying to achieve. thanks. 

Paulie78
Super User
Super User

You can use this expression:

trim(last(split(split(outputs('Compose'), decodeUriComponent('%0A'))[2], ':')))

You will need to modify it so outputs('Compose') is your string, example here:

2021-04-13_17-54-08.png

Output is: 12345

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (1,199)