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

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 III
Super User III

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 III
Super User III

@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 IV
Helper IV

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 III
Super User III

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
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

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.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,258)