cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Linn93
Helper I
Helper I

Update value of a choice field based on a different choice field value

Is it possible to update a value in a choice column based on the value in a different choice column in a sharepoint list within PowerApps?

 

I have a combobox in PowerApps where the user can change the value, I use Patch in a button to save changes in the combobox.

I want to update a status value in a choice-column based on the value in the combobox in powerApps.

 

My button where I patch the combobox to the SPlist looks like this:

 

 

Patch(

    SPlist,

    LookUp(

        SPlist,

        ID = varSelectedSPlist.ID

    ),

    {

       ChoicecolumninSPlist: ComboBox4.Selected}

);  

Refresh(SPlist);

Set(

    varSelectedSPlist,

    LookUp(

        SPlist,

        ID = varSelectedSPlist.ID

    )

);

 

 

 

What i want is:
if the ComboBox4 = "Yes", that a status column in SharePoint-list is updated to "Approved", and if the value in Combobox4 = "No", that the status column in the SharePoint list is updated to "Unapproved".

 

How can I change the value in the status column based on the value in ComboBox4 in this Patch button in PowerApps? And how should I write the syntax if this is possible to achieve in PowerApps?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions


@Linn93 wrote:

Hi @BCLS776 ,

 

info about my sharepoint-columns:
My sharepointlist is called: SPlist
Columns that are included in this button are:
Approved (choice-column), with following choices: Yes and No
Status (Choice-column), with following choices: Working, Approved, Unapproved
Globa variabel in PowerApps: varSelectedSPlist

The "Approved (choice-column)" has a combobox in the PowerApp and the Status (Choice-column) are not within the PowerApps, it is only in the SharePoint List.


Based on what you shared about your columns, try this syntax:

Patch(SPlist,
    LookUp(SPlist, ID = varSelectedSPlist.ID),
    If(ComboBox4.Selected.Value = "Yes",
        {
            Approved: ComboBox4.Selected,
            Status: {Value: "Approved"}
        },
        {
            Approved: ComboBox4.Selected,
            Status: {Value: "Unapproved"}
        }
    )
);

This code will change the Status of the record to Approved if the combobox was set to "yes"; otherwise, it will set the Status of the same record to Unapproved.

 

Bryan

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

View solution in original post

9 REPLIES 9
BCLS776
Super User
Super User

Give something like this a try:

Patch(SPlist,
    LookUp(SPlist, ID = varSelectedSPlist.ID),
    If(ComboBox4.Selected.Value = "Yes",
        {
            ChoicecolumninSPlist: ComboBox4.Selected,
            StatusColumninSPList: "Approved"
        },
        {
            ChoicecolumninSPlist: ComboBox4.Selected,
            StatusColumninSPList: "Unapproved"
        }
    )
);

Hope that helps,

Bryan

 

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

Thanks for your response @BCLS776

 

I attempted your suggestion: 

Patch(SPlist,
    LookUp(SPlist, ID = varSelectedSPlist.ID),
    If(ComboBox4.Selected.Value = "Yes",
        {
            ChoicecolumninSPlist: ComboBox4.Selected,
            StatusColumninSPList: "Approved"
        },
        {
            ChoicecolumninSPlist: ComboBox4.Selected,
            StatusColumninSPList: "Unapproved"
        }
    )
);

but then I receive the following error: "Invalid argument type (Boolean). Expecting a Record value instead".

Do you have any idea how I should rewrite the function to make it work? 

 

Many thanks. 

 

 

@BCLS776 , I also received the error: The type of this argument "StatusColumnSPlist" does not match the expected type "Record". Found type "Text".


@Linn93 wrote:

@BCLS776 , I also received the error: The type of this argument "StatusColumnSPlist" does not match the expected type "Record". Found type "Text".


Those column names I shared in the example code were examples only and will need to be modified to suit your Sharepoint List. To help you address the errors you are seeing, can you share details on the column names and types we are accessing in your list? The errors indicate we are trying to put the wrong kind of info into the column, e.g. trying to force a string of text into a column meant for a record

 

Bryan

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

@BCLS776 

I also tried with the following formula: 

 

 

Patch(
SPlist,
    LookUp(
        SPlist,
        ID = varSelectedSPlist.ID),
    If(ComboBox4.Selected.Value = "Yes",
        {
            ChoicecolumninSPlist: ComboBox4.Selected,
            StatusColumninSPList:{value:"Approved"}
        },
        {
           ChoicecolumninSPlist: ComboBox4.Selected.Value="No",
           StatusColumninSPList: "Unapproved"
        }
    )
);

 

 

I got rid of the error with this one. but the ChoicecolumninSPlist only update if I choose "Yes" and the StatusColumninSPList does not update at all.  

BCLS776
Super User
Super User

Please do share additional information on your Sharepoint columns. I'll point out the statement below is not correct syntax and will cause some errors:

BCLS776_0-1633730880741.png

 

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

Hi @BCLS776 ,

 

info about my sharepoint-columns:
My sharepointlist is called: SPlist
Columns that are included in this button are:
Approved (choice-column), with following choices: Yes and No
Status (Choice-column), with following choices: Working, Approved, Unapproved
Globa variabel in PowerApps: varSelectedSPlist

The "Approved (choice-column)" has a combobox in the PowerApp and the Status (Choice-column) are not within the PowerApps, it is only in the SharePoint List.


@Linn93 wrote:

Hi @BCLS776 ,

 

info about my sharepoint-columns:
My sharepointlist is called: SPlist
Columns that are included in this button are:
Approved (choice-column), with following choices: Yes and No
Status (Choice-column), with following choices: Working, Approved, Unapproved
Globa variabel in PowerApps: varSelectedSPlist

The "Approved (choice-column)" has a combobox in the PowerApp and the Status (Choice-column) are not within the PowerApps, it is only in the SharePoint List.


Based on what you shared about your columns, try this syntax:

Patch(SPlist,
    LookUp(SPlist, ID = varSelectedSPlist.ID),
    If(ComboBox4.Selected.Value = "Yes",
        {
            Approved: ComboBox4.Selected,
            Status: {Value: "Approved"}
        },
        {
            Approved: ComboBox4.Selected,
            Status: {Value: "Unapproved"}
        }
    )
);

This code will change the Status of the record to Approved if the combobox was set to "yes"; otherwise, it will set the Status of the same record to Unapproved.

 

Bryan

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

@BCLS776, this worked out perfectly! Thank you so much for your help.

 

 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,113)