cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Fernanda
Helper II
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

 

Fernanda_0-1619119453423.png

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??

Thank you in advance!!

1 ACCEPTED SOLUTION

Accepted Solutions

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.

View solution in original post

6 REPLIES 6
edgonzales
Super User II
Super User II

@Fernanda 

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

 

 

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.

Fernanda_0-1619121144012.png

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

 

Thanks for your help!!

 

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.

View solution in original post

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.

 

Fernanda_1-1619131400293.png

 

Maybe I wrote wrong the dynamic result?

Fernanda_2-1619131484168.png

 

 

@Fernanda 

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

You are a genius!! it totally worked!!

Tested all three and they worked perfectly!!

 

Fernanda_0-1619135105391.pngFernanda_1-1619135136396.pngFernanda_2-1619135172497.png

 

Thank you soooooo much!

 

Helpful resources

Announcements
MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

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

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

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