cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

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

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.

 

2 REPLIES 2
Highlighted
Super User II
Super User II

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

Highlighted
Anonymous
Not applicable

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.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Users online (11,769)