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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Power Fx Patch Status ...
Power Apps
Answered

Power Fx Patch Status Reason

(1) ShareShare
ReportReport
Posted on by 83

Hello everyone,

 

I am currently trying to change the status and status reason of a data record with a custom command bar button via Power Fx. Changing the status works without problems. However, I cannot change status reason. 

 

Below is my non-working code. Note: I'm German, so I have to use a semicolon instead of a comma and a double semicolon instead of a semicolon (https://docs.microsoft.com/en-us/power-platform/power-fx/expression-grammar#separators).

 

Patch(
 TableName;
 Self.Selected.Item;
 {
 Statusgrund: 'Statusgrund (TableName)'.'Lable of the status reason';
 Status: 'Status (TableName)'.Inaktiv
 }
);;

 

 

After typing Statusgrund: 'Statusgrund (TableName)'. entered, the code completion suggests only the two options Aktiv and Inaktiv. Which leads to the default value of the respective status. Can someone explain me how to use the status reason here? I have already tried to use the value (number) of the status reason: Statusgrund: 'Statusgrund (TableName)'.'4'. I also tried to use the shed and attach the reason: Statusgrund: 'Statusgrund (TableName)'.Inaktiv.'Lable of the status reason'.

 

Thank you and best regards
Nico

Categories:
I have the same question (0)
  • jorge.daniel Profile Picture
    1,430 Super User 2024 Season 1 on at

    Hi,

     

    Status Reason have a related Status, so you cannot have a Status of Active and a Status Reason of Inactive (I mean by default since you can change the default Status Reason).

     

    Try changing first the Status and then the Status Reason.

  • HS_Nico Profile Picture
    83 on at

    Unfortunately that doesn't work either. Even if the status reason belongs to the current status.

    I am unable to change the status reason using patch.

  • jorge.daniel Profile Picture
    1,430 Super User 2024 Season 1 on at

    Have you enabled status reason transitions?

  • HS_Nico Profile Picture
    83 on at

    Okay, the problem is getting pretty confusing.

     

    I am able to change the active status reasons. It doesn't matter whether the current status is active or inactive. And I can change the status to inactive. But what doesn't work is to set one of the inactive status reasons. It doesn't matter whether the status is already inactive or not.

     

    That works

     

    Patch(
     TableName;
     Self.Selected.Item;
     {
     Status: 'Status (TableName)'.Aktiv;
     Statusgrund: 'Statusgrund (TableName)'.'2'
     }
    );;

     

     

    That works too

     

    Patch(
     TableName;
     Self.Selected.Item;
     {
     Status: 'Status (TableName)'.Inaktiv
     }
    );;

     

     

    That doesn't work

     

    Patch(
     TableName;
     Self.Selected.Item;
     {
     Status: 'Status (TableName)'.Inaktiv;
     Statusgrund: 'Statusgrund (TableName)'.'4'
     }
    );;

     

     

  • jorge.daniel Profile Picture
    1,430 Super User 2024 Season 1 on at

    Statusgrund 4 is an Inactive Status?

     

    status.PNG

  • HS_Nico Profile Picture
    83 on at

    Yes, exactly. Status Reasons 1 and 2 are Active Statuses and 3 through 6 are Inactive Statuses. An error (underlined in red) is only displayed in the code for the inactive status.

  • jorge.daniel Profile Picture
    1,430 Super User 2024 Season 1 on at

    and when you patch no error is returned? Are you sure you have no statuses transitions setup?

  • HS_Nico Profile Picture
    83 on at

    I just checked again: status reason transitions are disabled.

     

    When I press the created button in the model-driven app, I get an error message. But it doesn't contain a lot of information. Only the error code "0x0", the session id, the activity id and the time.

  • jorge.daniel Profile Picture
    1,430 Super User 2024 Season 1 on at

    When you hover through that red underline, there should be an indication of whats wrong. What does it read?

  • HS_Nico Profile Picture
    83 on at
    That's the code:

     

    Patch(
     TableName;
     Self.Selected.Item;
     {
     Status: 'Status (TableName)'.Inaktiv;
     Statusgrund: 'Statusgrund (TableName)'.'4'
     }
    );;

     

     
    And these are the error messages:
    • The function 'Patch' has some invalid arguments.
    • The type of this argument 'statuscode' does not match the expected type 'OptionSetValue'. Found type 'Error'.
    • The name is invalid. "4" is not recognized.

    In my opinion the main problem is that I can't reach the inactive status reasons. This means that this Statusgrund: 'Statusgrund (TableName)'.'4' doesn't work even though this Statusgrund: 'Statusgrund (TableName)'.'2' works.

    I also just checked again: both status reasons exist with the respective values. The only difference is that 2 is an active status reason and 4 is an inactive status reason.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard