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?
Solved! Go to Solution.
@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: varSelectedSPlistThe "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
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
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
@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.
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:
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: varSelectedSPlistThe "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
User | Count |
---|---|
250 | |
102 | |
94 | |
47 | |
37 |