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

How to assign Sharepoint list field values on Submit that are not on the Form

Hello all, I am new to PowerApps. I have a form with bunch of fields from SharePoint list. Since those fields are on the form in various cards, onsubmit it saves the data into respective fields. I have additiional fields in the list (i.e. Logged in User Name, Current Users Email etc.). I want to assign values to these fields using some logic or hard-coded value as user submits the form. i.e. When user submits - I want to save the form fields data + following - in Logged in User Name = Current SharePoint User, - in Current Users Email = Current SharePoint Users Email Address - in Date Submitted = Today's Date - in Status = "Submitted" Please help. Regards, Nick
1 ACCEPTED SOLUTION

Accepted Solutions
Nick2020
Level: Powered On

Re: How to assign Sharepoint list field values on Submit that are not on the Form

Hi gsivasai,

 

Perfect. That worked!!! Thanks so very much. Let me try adding other fields. 

 

Kind regards,

Nick

9 REPLIES 9
Highlighted
gsivasai
Level: Powered On

Re: How to assign Sharepoint list field values on Submit that are not on the Form

@Nick2020 Do the fields types you are requiring to populate look right? - Logged in User - Person field Current Users Email - Single Line Text field Status - Single Line text or Choice field? Also, do you need for these fields to be populated every time the form is submitted or is it a one time action?
Nick2020
Level: Powered On

Re: How to assign Sharepoint list field values on Submit that are not on the Form

Hi gsivasai,

 

Thanks for the response. 

 

The field types are correct as below - 

1. Logged in User - Single Line Text  

2. Current Users Email - Single Line Text field

3. Status - Choice field.

 

Basically, #1 and #2 field are one time only as user submit the initial intake form.

#3 Status field I would like to set initially to Submitted. Which after submission, the admin users will have ability to change the status by selecting the choices from dropdown.

 

Please let me know if I could explain better. I look forward to the pointers to achieve this.

 

Kind regards,

nick

gsivasai
Level: Powered On

Re: How to assign Sharepoint list field values on Submit that are not on the Form

Hi @Nick2020,

 

Here's how you could update those fields using the Patch() function:

  • OnStart or Visible of your app primary screen set the following to retrieve current user's info using the User() function.
    Set(currentUser, User())
  • Set the following on submit event of your form.
    Replace the logic in the If condition to how you'd want to determine that it's a first time submission.
    Replace 'SourceList' with your List name.
    Specify the item id you are requiring to update.
    The Status field needs to be handled a bit differently since its a complex field. You will have to specify the Id (index) of the choice value. They are 1 based index (For e.g. If your choice field values are Draft, Submitted & Completed then the ID for Submitted would be 2). The value would be the text value for that choice.
    If(<condtion logic>,Patch(SourceList,{ID:<ItemId>},
            {   
                SubmittedBy: currentUser.FullName,
                SubmitterEmail: currentUser.Email,
                Date: Today(),
                Status: {
                    '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
                    Id: 2,
                    Value: "Submitted"
                }
            }));
            SubmitForm(MyForm)
    Also, replace the field names (Status, SubmitterEmail, Date etc) to match teh field displaynames in your list.

 

 

Nick2020
Level: Powered On

Re: How to assign Sharepoint list field values on Submit that are not on the Form

Hi Gsivasai, Thanks for the response. I tried the just updating one field first. For the new form condition, I am not getting the RequestDate updated. It seems it is not getting the correct ID or ID is coming blank. Please let me know how to check if this is the new form. I want to set these values only when a user submits the form first time. (Except Status field, they should not be able to change it in future Edit screens). Following is what I tried to update RequestDate - If(SharePointForm1.Mode = New, Patch(List_Request,{IDSmiley FrustratedharePointForm1.LastSubmit.ID}, { RequestDate:Today() })); SubmitForm(SharePointForm1)
Nick2020
Level: Powered On

Re: How to assign Sharepoint list field values on Submit that are not on the Form

Hi Gsivasai,

 

Thanks for the response.

 

I tried the just updating one field first.

 

For the new form condition, I am not getting the RequestDate updated.

 

It seems it is not getting the correct ID or ID is coming blank.

 

Please let me know how to check if this is the new form. I want to set these values only when a user submits the form first time. (Except Status field, they should not be able to change it in future Edit screens).

 

Following is what I tried to update RequestDate 

 

If(SharePointForm1.Mode = New, Patch(List_Request,{IDSmiley FrustratedharePointForm1.LastSubmit.ID},
       {   
            RequestDate:Today()
        })); SubmitForm(SharePointForm1)
        
gsivasai
Level: Powered On

Re: How to assign Sharepoint list field values on Submit that are not on the Form

The ID is blank is because the item hasn't been created in the first place. How about we try this?-

If(
    SharePointForm1.Mode = New,
    Patch(
        List_Request,
        {ID: Blank()},
        SharePointForm1.Updates,
        { RequestDate: Today()}
),
    SubmitForm(SharePointForm1)
)

The above is patching a new item with all the updates to the form along with current date for the RequestDate field if the form mode is "New". Else, the entire form is submitted without custom values.

ID:Blank() is a way to tell SP that it's patching a brand new item.

Nick2020
Level: Powered On

Re: How to assign Sharepoint list field values on Submit that are not on the Form

Hi gsivasai,

 

Perfect. That worked!!! Thanks so very much. Let me try adding other fields. 

 

Kind regards,

Nick

Nick2020
Level: Powered On

Re: How to assign Sharepoint list field values on Submit that are not on the Form

Thanks gsivasai. I appreciate all help. The solution was perfect. 

 

Regards,

nick

Rodolfo1840
Level: Powered On

Re: How to assign Sharepoint list field values on Submit that are not on the Form

Thanks @gsivasai !

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Next Wednesday, September 18th at 8am PDT

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

Users Online
Currently online: 54 members 4,464 guests
Please welcome our newest community members: