cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mark-carlisle
Helper II
Helper II

True/False not working as expected

I am extracting information from an email to create a SharePoint list using this expression;

 

substring(triggerBody()?['Body'],add(indexOf(triggerBody()?['Body'],'Registration'),30),sub(indexOf(triggerBody()?['Body'],'Version Number'),add(indexOf(triggerBody()?['Body'],'Registration'),30)))

The above works and produces this result;

 

SerialNo AD Netwrk ProductCode

 

What I want to achieve is either a 'Yes' or 'No' output on the SharePoint list, e.g. if what is extracted with the above expression has 'Netwrk' then the output should be 'Yes'. The expression I have is;

 

if(equals(contains(substring(triggerBody()?['Body'],add(indexOf(triggerBody()?['Body'],'Registration'),30),sub(indexOf(triggerBody()?['Body'],'Version Number'),add(indexOf(triggerBody()?['Body'],'Registration'),30))),'CLIENT'),'true'),'YES','NO')

Which produces 'No'. Some troubleshooting has found that this part of the expression returns the correct result, 'True';

 

contains(substring(triggerBody()?['Body'],add(indexOf(triggerBody()?['Body'],'Registration'),30),sub(indexOf(triggerBody()?['Body'],'Version Number'),add(indexOf(triggerBody()?['Body'],'Registration'),30))), 'Netwrk')

So I increased the complexity to;

 

equals(contains(substring(triggerBody()?['Body'],add(indexOf(triggerBody()?['Body'],'Registration'),30),sub(indexOf(triggerBody()?['Body'],'Version Number'),add(indexOf(triggerBody()?['Body'],'Registration'),30))), 'Netwrk'),'True')

However this then returns 'false' which is why my 'if' statement is saying 'No', unfortunately this is as far as my knowledge is taking me so any suggestions on where I'm going wrong with this would be appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
mark-carlisle
Helper II
Helper II

Overcomplicating it...

 

if(contains(substring(triggerBody()?['Body'],add(indexOf(triggerBody()?['Body'],'Registration'),30),sub(indexOf(triggerBody()?['Body'],'Version Number'),add(indexOf(triggerBody()?['Body'],'Registration'),30))),'Netwrk'), 'Yes','No')

View solution in original post

2 REPLIES 2
mark-carlisle
Helper II
Helper II

Overcomplicating it...

 

if(contains(substring(triggerBody()?['Body'],add(indexOf(triggerBody()?['Body'],'Registration'),30),sub(indexOf(triggerBody()?['Body'],'Version Number'),add(indexOf(triggerBody()?['Body'],'Registration'),30))),'Netwrk'), 'Yes','No')

Hi @mark-carlisle,

 

The true quoted would be treated as string value, while the contains () function returns a boolean value, t omake the Equals work, we should convert the true to a boolean value with the Bool() function:

equals(
  contains(substring(triggerBody()?['Body'],
                   add(indexOf(triggerBody()?['Body'],'Registration'),30),
                          sub(indexOf(triggerBody()?['Body'],'Version Number'),
                                add(indexOf(triggerBody()?['Body'],'Registration'),30)
                               )
                     ), 
            'Netwrk'),
bool(1))

Function reference.

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

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.

Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022- Season 2 has kicked off!

Users online (3,865)