web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Power Apps Portal If s...
Power Pages
Unanswered

Power Apps Portal If statements not worknig

(0) ShareShare
ReportReport
Posted on by 6

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 ?

 

Categories:
I have the same question (0)
  • H V Profile Picture
    1,510 on at

    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!

     

  • FenrirZA Profile Picture
    6 on at

    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%}

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
11manish Profile Picture

11manish 52

#2
Valantis Profile Picture

Valantis 46

#3
Vish WR Profile Picture

Vish WR 29

Last 30 days Overall leaderboard