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

Submitting Global Variable values to Sharepoint Lists

Hi, 

 

I am new to Powerapps and have tried to follow other threads but not having much luck.

 

I have an app that asks some questions but I have set a global variable for each question such as age, gender, etc. I also made a Sharepoint list with columns that are Age, Gender, etc and what I want is to click a submit button it will move the values chosen of each variable selected into their corresponding columns as one row. 

 

I have tried using Collect and Patch functions and getting errors. I have somehow ended up with the code using for example Collect(SPList, {Title:age}) and it has filled in the first column but am not sure how to edit this code to include the other variables to appear in their respective columns as my attempts have had the columns come out as blank. 

 

If anyone can help, that would be great. 

 

 

10 REPLIES 10
Super User
Super User

Re: Submitting Global Variable values to Sharepoint Lists

You need to use Patch or UpdateIf to modify sharepoint.

 

For a new record:

 

Patch(SPList,Defaults(SPList),{Age:AgeVariableName,Ethnicity:EthnicityVariablename})

Also ensure you havnt got any 'Required' fields such as 'Title' as this will stop the Patch applying.

 

If you decide at some point you want to modify a sharepoint record i would use UpdateIf as Patch will not update a Null value (i have reported many times now)

 

Oh and so your clear:

Collect: Pulls records into powerapps and stores them in temporary tables

Patch: Adds or modifies a record in a datasource or collection

UpdateIf: Modifies a record in a datasource or collection

 

 

andy88
Level: Powered On

Re: Submitting Global Variable values to Sharepoint Lists

Thanks for your quick response. 

 

I actually unrequired Title and renamed it Age as I thought it would be easier.

 

Not sure if that might be causing problems, as I have previously tried this code before and its saying 'The specified column 'Age' (& Ethnictiy) does not exist. I have definitely set up the columns as you saw from the image attachement in my initial post, would you be able to provide more guidance on this. 

Super User
Super User

Re: Submitting Global Variable values to Sharepoint Lists

Powerapps doesnt like renamed columns.  Add a form and set its source to the sharepoint list, it will then show you the columns you can choose from, youll be able to find the new name then.  Make sure you have removed and readded the datasource aswell after you renamed it.

andy88
Level: Powered On

Re: Submitting Global Variable values to Sharepoint Lists

So I added the form just to see the columns and I followed exactly how the column is presenting with age I even changed it to a capital A and the same with ethnicity. It is still saying these columns do not exist.. 

Super User
Super User

Re: Submitting Global Variable values to Sharepoint Lists

Sorry missed a bit out..

 

On the form, add the field, then check under that item: (heres one of mine that was renamed, i have to refer to h29t rather than the actual name)

 

Capture.PNG 

Super User
Super User

Re: Submitting Global Variable values to Sharepoint Lists

to be honest though, youll be better off creating a new column (do it from classic sharepoint not just by clicking the little plus button) and deleting the old column.

 

The only reason i havnt is that i have 50+ columns and a lot of data and would mean changing so much.

andy88
Level: Powered On

Re: Submitting Global Variable values to Sharepoint Lists

Wow thanks! Would have never known to look there, it seems to be working. 

 

I also wanted to ask quickly another query. My very first question is from a dropdown listand I want to patch whatever the option they chose there. Do you know the code for this as I am trying Patch(Contact,Dropdown_Name.Selected) and it does not seem to be working. Also on the SP list, would the type of the column for this dropdown be a choice or would it still be single line of text? 

Super User
Super User

Re: Submitting Global Variable values to Sharepoint Lists

Patch(Contact,Defaults(Contact),{ColumnName:Dropdown_Name.Selected.Value})

need to add .Value to the end of Selected where Value = the fieldName, so if you have a table as your dropdown datasource then Value would be the name of the column.

 

if its an existing record then replace Defaults(Contact) with a formula such as ID=Lookup.....

 

UpdateIf works better if its an existing record aswell, i only use patch if its a new record as it cant update null values in an existing record.

andy88
Level: Powered On

Re: Submitting Global Variable values to Sharepoint Lists

Hi so if I was to add that code as part of the submit button that previously discussed would it be: 

 

 

Patch(
    SPList,Defaults(SPList),
    {ColumnName:DropdownName.Selected.Value}) 

I have tried this but it is not recognising the Selected.Value saying its an invalid Name. 

 

Also on the SP List, do you know what type of data the column should be, such as single line of text or choice? 

Helpful resources

Announcements
thirdimage

Power Apps Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Kudoed Authors (Last 30 Days)
Users online (4,136)