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

Helpful resources

Announcements
MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

PA Survey Carousel Image.png

We want to hear from you!

If you are a small business ISV/Reseller, share your thoughts with our research team.

Users online (3,012)