cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Robert94
Post Patron
Post Patron

How to make this work for a Lookout type of Column: Update - If(locStatus,{Value:"Draft"},{Value:"Submitted"}) ?

When I press a button I want to change the status of a list. So:

Save button - changes status to draft - OnSelect - UpdateContext({locStatus:false});

Submit button - changes satus to submit - OnSelect - UpdateContext({locStatus:true});

On the forms datacard that cotains the status column - Update - If(locStatus,{Value:"Draft"},{Value:"Submitted"})

Now, this only works when the type of the column is Choices, but my type is a Lookout to another sharepoint list in which that column contains 2 row (draft and submitted), how do i make this formula to work in my case?

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Robert94 ,

Neither form - you need to look up the List with the Title field you mentioned - also note Id, not ID in the reference.

With(
   {
      wStatus:
      If(
         locStatus,
         "Draft",
         "Submitted"
      )
   },
   {
      Id: 
      LookUp(
         YourStatusListName, 
         Title = wStatus
      ).ID, 
      Value: wStatus
   }
)

A better idea is to ask yourself why you are using Lookup columns (I have not used them for many years) unless you want to interact with the field directly in SharePoint - I have a blog on Data Structure that may interest you.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

View solution in original post

4 REPLIES 4
v-qiaqi-msft
Community Support
Community Support

Hi @Robert94,

Do you mean that the Status column is a LookUp column retrieving values from another SP list?

Could you please share a bit more about your scenario?

 

If the Status is indeed a LookUp column, you should modify your formula as below:

If(locStatus,
       {
        Id:LookUp(AnotherSPList,Status="Draft").ID
        Value:"Draft"},
       {
        Id:LookUp(AnotherSPList,Status="Submitted").ID
        Value:"Submitted"}
   )
Best Regards,
Qi
Robert94
Post Patron
Post Patron

HI, so there are 2 forms, one main called MasterForm, one for the Status called StatusForm,

in the MasterForm there is a column called Status, its a Lookout type to the Title column of the StatusForm, the title column of the StatusForm has 2 rows, called Draft, and Submitted.

On screen the Forms data source is MasterForm.

What I want: 

-when pressing Save button : Status of the form changes to Draft, and then Submits the form.
-but if pressing Submit button: Status should change to Submitted, and then Submits the form

Why?
- I will use a filter for a MasterForm gallery to filter items by the Status, Draft or Submitted.

I can.t make your formula to work, if you could help me more. Thank you.

This is how I wrote it
If(locStatus,{ID:LookUp(StatusForm, Status="Draft").ID, Value:"Draft"},{ID:LookUp(StatusForm, Status="Submitted").ID, Value:"Submitted"})
Shouldn`t the If function be addressed to the MasterForm instead of the StatusForm?

Hi @Robert94 ,

Neither form - you need to look up the List with the Title field you mentioned - also note Id, not ID in the reference.

With(
   {
      wStatus:
      If(
         locStatus,
         "Draft",
         "Submitted"
      )
   },
   {
      Id: 
      LookUp(
         YourStatusListName, 
         Title = wStatus
      ).ID, 
      Value: wStatus
   }
)

A better idea is to ask yourself why you are using Lookup columns (I have not used them for many years) unless you want to interact with the field directly in SharePoint - I have a blog on Data Structure that may interest you.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

WarrenBelz
Super User
Super User

Hi @Robert94 ,

Just checking if you got the result you were looking for on this thread. Happy to help further if not.

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Top Solution Authors
Users online (4,849)