cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
FenrirZA
New Member

Power Apps Portal If statements not worknig

I'm keep experiencing a problem where the if control statements do not function correctly.

 

I'm trying to complate a interger value from a fetchxml query but when doing so the value does not match the compared value.

 

{% fetchxml cases %}
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="incident">
<attribute name="statecode" />
<filter type="and">
<condition attribute="incidentid" operator="eq" uiname="XXXXXXXXX" uitype="incident" value="{{request.params['caseid']}}" />
</filter>
</entity>
</fetch>
{% endfetchxml %}
{% if cases.results.entities.size > 0 %}
{%assign caseobj = cases.results.entities[0]%}
{%assign contractname = caseobj.icas_contractnew.name%}
{%assign contractid = caseobj.icas_contractnew.id%}
{%assign case_status = caseobj.statecode%}
 
{%if case_status == 0%} 
ACTIVE
{%else%}
INACTIVE
{%endif%}
 
{%endif%}

//////////////////////////

 

The code that is giving a problem is the following: {%if case_status == 0%}  try as I might it does not recognise the 0 even though the output from the case_status is 0.

 

I've changed the assign code to {%assign case_status = caseobj.statecode|plus:0%} to force numeric but this also does not work.

 

Any advise would be great ?

 

2 REPLIES 2
hardikv
Memorable Member
Memorable Member

Hi @FenrirZA 

 

In Optionset field you need to use "label" & "value".

 

{%assign case_status_value = caseobj.statecode.value%}
{%assign case_status_label = caseobj.statecode.label%}
 
{%if case_status_value == 0%} 
ACTIVE
{%else%}
INACTIVE
{%endif%}

{%if case_status_label == "Active "%} 
ACTIVE
{%else%}
INACTIVE
{%endif%}

 

--------------------------
If you like this post, give a Thumbs up. Where it solved your query, Mark as a Solution so it can help other people!

 

I've tried the caseobj.statecode.value and assigned that to a variable. I know the variable contains the data seeing I can output it. But when I do the if statement it does not work.

 

{%assign case_status_value = caseobj.statecode.value%}
{%assign case_status_label = caseobj.statecode.label%}

//Does not Work
{%if case_status_value == 0%}
ACTIVE
{%else%}
INACTIVE
{%endif%}

 

 

//Does Work
{%if caseobj.statecode.value == 0%}
ACTIVE
{%else%}
INACTIVE
{%endif%}

 

Helpful resources

Announcements
Carousel Community Blog

Check out the Community Blog

Read all about the most recent blogs in the community!

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Carousel News & Announcements

What's New in the Community?

Check out the latest News & Events in the community!

Users online (4,040)