cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JDpower
Level: Powered On

How to patch a text field to a multi select choice column in sharepoint

Hello Friends,

 

I'm new to PowerApps and trying to achieve a solution for the following Problem:

I have a Text field where the user will Provide Regions in the the following formats(either 1, 2 or 3)

1. ASPAC,LATAM,NA

2. GLOBAL, NA

3. EMEA

 

And as per their choice in the text field I have to Patch this Text in a multi select Choice field (Region) which already has those choices available.

ie,

ASPAC

LATAM

NA

EMEA

GLOBAL

 

 

I'm trying to use the following code on Save button click but it's not working.

 

Patch('Employee Details', Defaults('Employee Details'), {

Region:

{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
Id:1,
Value:InputRegion.Text}

})

 

Any help will be much appreciated!! 

 

4 REPLIES 4
Community Support Team
Community Support Team

Re: How to patch a text field to a multi select choice column in sharepoint

Hi @JDpower,

 

Could you please share a bit more about the error message within your app?

Do you want to save each region within the Text field into the Multiple Choice type column in your SP list?

 

I think there is something wrong with the formula that you provided. Because the Region column is a Multiple Choice type column in your SP list, you should provide a Table value for the Region property rather than an object value within the formula that you provided.

 

 

I have made a test on my side, please take a try with the following workaround:1.JPG

 

 

Set the OnSelect property of the "New Item" button (it is "Save" button) to following formula:

Clear(Collection1);
Clear(RegionTable); ForAll(Split(TextInput1.Text,","),Collect(Collection1,{Iterator:CountRows(Collection1),Value:Result})); ForAll(
Collection1,
Collect(
RegionTable,
{
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference", Id: Iterator, Value: Value
}
)
); Patch('20180713_case6',Defaults('20180713_case6'),{Title:"PowerApps Creation",Region:RegionTable})

On your side, you should type the following formula:

Clear(Collection1);
Clear(RegionTable);
ForAll(Split(TextInput1.Text,","),Collect(Collection1,{Iterator:CountRows(Collection1),Value:Result}));
ForAll(
     Collection1,
     Collect(
             RegionTable,
             {
              '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
               Id: Iterator,
               Value: Value
             }
           )
);
Patch('Employee Details',Defaults('Employee Details'),{Title:"PowerApps Creation",Region:RegionTable})

Note: Please add the Title property (Title column, which is a required column) within your formula.

 

The GIF image as below:Test1.gif

 

 

 

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
JDpower
Level: Powered On

Re: How to patch a text field to a multi select choice column in sharepoint

Hello Kris,

 

Your suggestion works, however that is working when I'm saving the value one by one. I have a collection(EmployeeCollection) which I'm looping through  to feed different employee Details each having Employeename,Project Priority, Region in Employee Details list. I'm saving the text data in EmployeeCollection as Project Region each time after hitting a Save button and when we finally hit Submit button we patch it to Employee Details list.All is working but I'm unable to put

Clear(Collection1);
Clear(RegionTable);

inside the ForAll function of Submit button.Also let me know whether I should create the Region table anywhere else or any workaround.Kindly look below for codes

 

 

Save Button (hitting multiple times to save new data in EmployeeCollection)

Patch(EmployeeCollection, ThisItem, {EmployeeNameItem:inputname.Text,ProjectPriority:Radio1.Selected.Value,ProjectRegion:Textinput1.Text});
Collect(EmployeeCollection,{EmployeeNameItem:"",ProjectRegion:"",ProjectPriority:"",})

 

Submit Button(Hitting one final time to save data from EmployeeCollection to Employee Details)

ForAll(EmployeeCollection, If(!IsBlank(EmployeeNameItem),

Clear(Collection1);
Clear(RegionTable);
ForAll(Split(ProjectRegion,","),Collect(Collection1,{Iterator:CountRows(Collection1),Value:Result}));

ForAll(
Collection1,
Collect(
RegionTable,
{
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
Id: Iterator,
Value: Value
}
)
);

Patch('Employee Details', Defaults('Employee Details'), {Title:EmployeeNameItem,Priority:
{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
Id:1,
ValueSmiley TonguerojectPriority},Region:RegionTable,MID:Form1.LastSubmit.ID })));

 

Thanks and Regards.

JD

Community Support Team
Community Support Team

Re: How to patch a text field to a multi select choice column in sharepoint

Hi @JDpower,

 

I have made a test and the issue is confirmed on my side.

 

Currently, we could not put Clear function within a ForAll function in PowerApps. As an alternative solution, you could consider take a try to put them outside the ForAll function.

 

Please modify your formula within the OnSelect property of the "Submit" button as below:

Clear(Collection1);
Clear(RegionTable);
ForAll(
    EmployeeCollection,
    If(
        !IsBlank(EmployeeNameItem),
        ForAll(Split(ProjectRegion,","),Collect(Collection1,{Iterator:CountRows(Collection1),Value:Result}));
        ForAll(Collection1,
               Collect(RegionTable,
                   {
                    '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
                     Id: Iterator,
                     Value: Value
                   }
                )
              );
         Patch(
               'Employee Details',
                Defaults('Employee Details'),
                {
                  Title:EmployeeNameItem,
                  Priority:{
                     '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
                      Id:1,
                      Value:ProjectPriority
                    },
                    Region:RegionTable,
                    MID:Form1.LastSubmit.ID
                }
              )
    )
)

Please take a try with above solution that I provided, then check if the issue is solved on your side.

 

If the issue is solved on your side, please go ahead and click “Accept as Solution” so that this thread will be marked for other users to easily identify.

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
JDpower
Level: Powered On

Re: How to patch a text field to a multi select choice column in sharepoint

Hello Kris,

 

The data is getting submitted however there is overlap from the second entry. Say in the 1st entry of EmployeeCollection the region had EMEA, NA as input that is going ok , but from second entry onwards the value is getting appended.

As for 2nd entry if region is GLOBAL,ASPAC in list I can find EMEA,NA, EMEA,NA,GLOBAL,ASPAC.

 

Maybe because the clear funtions are outside Forall the Region Table and collection is not getting cleared for each entry.

Hope you can help.

 

Regards,

JD

Helpful resources

Announcements
firstImage

PowerApps Monthly Community Call!

Join us next Wednesday for our Demo Extravaganza, October 16, 2019 8am PDT.

firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 152 members 3,773 guests
Recent signins:
Please welcome our newest community members: