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 / Is it possible to patc...
Power Apps
Unanswered

Is it possible to patch the CDS standard "Status" column from a canvas app?

(0) ShareShare
ReportReport
Posted on by

I have googled all over the place, watched videos etc and I'm just not getting this to work. I can't even find the optionsetvalues because there are no elipses in the field info box to click like most of the explanations on line say to use. I followed Daniel Christian's video on this topic with option sets and dug into the dynamics admin menu and found the field but even there, there's no edit button for me to look at the actual values. I've tried using 0 and 1 but powerapps tells me it's the wrong data type. Is this futile? I guess I could just use custom columns for what I'm trying to do but this seems like it should be very very straight forward. Thanks in advance.

 

I have the same question (0)
  • GarethPrisk Profile Picture
    2,828 on at

    You can set the default status using the Defaults() function in your patch.

    Patch(Accounts, Defaults(Accounts), {name: "Account Name"})

    If you are trying to explicitly set the Status, you may need to consider:

    • Setting both the statecode and statuscode fields at the same time
      • There are not the same thing
      • statecode is typically whether the record is Active (0) or Inactive (1)
      • statuscode describes more of the 'Status Reason'
    • The statecode and statuscode values are paired, and you'll need to know what are valid pairings
      • Cannot set an 'active' statuscode with the 'Inactive' statecode, for example
    • You can typically reference the Option Set  / Status fields by referencing the field
      • statecode: 'Status (Accounts)'.Inactive,
      • statuscode: 'Status Reason (Accounts)'.Inactive
    • It does appear as though Canvas apps, and Patches, cannot set a State/Status code for create (unlike other API calls)
      • This may be due to a conflict with using Defaults()
      • If you don't use Defaults(), you'll have to play whack-a-mole to determine all the fields it wants set
    • You can, however, Patch the Account and immediately update the status
      • See below

    Create and then Update Status (using Account in CDS, as example)

    UpdateContext(
     {
     locAccount: Patch(
     Accounts,
     Defaults(Accounts),
     {name: "Inactive Account"}
     )
     }
    );
    Patch(
     Accounts,
     locAccount,
     {
     statecode: 'Status (Accounts)'.Inactive,
     statuscode: 'Status Reason (Accounts)'.Inactive
     }
    )

    MSFT Docs on Entity State/Status

  • Community Power Platform Member Profile Picture
    on at

    I gave up on using the status column for what I was trying to do and just made a custom two option column. What I'm doing with it is fairly simple...make a templatefill flash or not flash. The status column, given its complexity, seems like killing a bug with a sledgehammer. Thank you for your help though.

  • Community Power Platform Member Profile Picture
    on at

    I'm pretty sure that Canvas Apps can no longer do this.  I've tried every conceivable way with Patch(). Not sure when exactly they changed it, but I think if you try your code above, you'll get errors setting statecode and statuscode.

  • Community Power Platform Member Profile Picture
    on at

    Sorry. I have to retract that statement. The "monitor" page indicated that a particular Patch() statement was getting an error so I thought this was the case. But it was actually a problem with a different Patch() statement than the one monitor highlighted. Misleading. Anyway, it does work.

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 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard