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
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Users online (2,204)