cancel
Showing results forย
Did you mean:ย
Helper II

## IF logic

Hi

I need some help with IF function and Startswith. I have been reading several posts about this but they have not been very helpful with my issue, which I think is quite simple, but makes me feel so stupid that I cant break it down haha

I have a flow where I am reading the headline of an email and I am extracting a 10 digit number that goes into a sharepoint list as "Title".

This number can have 3 different formats. It can begin with 100, 101 or 102.

And here is where I need to use my IF and Startswith formulas

"Tipo de Pedido value" is a choice column in my sharepoint, where the logic is: 100 = ZNAC, 101=ZPEM and 102=ZPRY, so I need to select the value according to the 3 digits of that 10 digit number in Title. I tried many things, even the logic from excel, but everything keeps failing.

Do you have any ideas??

1 ACCEPTED SOLUTION

Accepted Solutions
Super User II

Try this:

if(startsWith(triggerBody()['text'],'100'), 'znac',
if(startsWith(triggerBody()['text'],'101'), 'zpam',
if(startsWith(triggerBody()['text'],'102'), 'zpry', 'something else'
)))

Swapping out the triggerBody()['text'] bit with the dynamic value of your SP title.  Note the single quotes around the numbers as they are probably formatted as text in your SP list.

Keep us posted.

-Ed

If you liked this reply, please give it a thumbs up! If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

6 REPLIES 6
Super User II

Hi there.  A couple of thoughts:  A "Switch" action might work well here once you have the digits parsed out.  As far as parsing out the numbers, can you give the context of the entire headline of the email?  We might be able to use Split() or something similar to get at what you want.

...nm, I see you're grabbing the 10 digits from the SP list, not the email.  Would it be possible to have the ZNAC stuff populate in SP instead?

Thanks!

-Ed

Helper II

Hi Ed!

Yes, of course. This flow is helping us create a database in sharepoint. We create the item based on the number of the request written on the email headline.

As shown in this example, my headline was converted to plain text and we extracted with substring the request number.

So now, with this number, I must determine what kind of request is: ZNAC is for this request ID begins with 100, ZPRY begins with 102 and ZPEM begins with 101. And that sorting goes into a column named "Tipo de Pedido", which is a choice column (ZNAC, ZPEM, ZPRY)

That is what I am trying to build

Super User II

Try this:

if(startsWith(triggerBody()['text'],'100'), 'znac',
if(startsWith(triggerBody()['text'],'101'), 'zpam',
if(startsWith(triggerBody()['text'],'102'), 'zpry', 'something else'
)))

Swapping out the triggerBody()['text'] bit with the dynamic value of your SP title.  Note the single quotes around the numbers as they are probably formatted as text in your SP list.

Keep us posted.

-Ed

If you liked this reply, please give it a thumbs up! If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

Helper II

Hey!

I tried your idea... and I am pretty sure I must be doing something wrong.

I replaced as mentioned,

if(startsWith('Salidas','100'), 'ZNAC',
if(startsWith('Salidas','101'), 'ZPEM',
if(startsWith('Salidas','102'), 'ZPRY', 'something else'
)))

I tested it, and with the request ID I had, the result should had been ZNAC, but instead it said something else.

Maybe I wrote wrong the dynamic result?

Super User II

You are exactly correct.  Where you have 'Salidas', you want to highlight that whole thing (including the single quotes) and delete it.  Then, making sure your cursor is still in the same place after "startswith(", switch over to your dynamic values and click on the output of the step "Redactar".

The way you had the expression, it is looking at the word 'Salidas' to see if it starts with 100, rather than checking the dynamic value.  Give that a go and let us know how it works.  I'm stepping out for a bit, but can post a quick video of adding the dynamic value when I get back if you're still having trouble.

Good luck!

-Ed

Helper II

You are a genius!! it totally worked!!

Tested all three and they worked perfectly!!

Thank you soooooo much!

Announcements

#### Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Check out how to claim yours today!

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (46,312)