web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Form in DisplayMode Ne...
Power Apps
Answered

Form in DisplayMode New - How to save Attachments to SharePoint List

(0) ShareShare
ReportReport
Posted on by

Hi, 

I have a submit button and the OnSelect looks like so;

 

Patch(
         'SharePointList 1',
         {
                 'Component Type': ComboBox_Type.Selected,
                 'Component Name': TextInput_Name.Text
         }
);

Patch(
         'SharePointList 2',
          {
               'Component Version':TextInput_Version.Text,
               'Component Description': TextInput_Description.Text,
               'Component Name':
                {
                        Value: TextInput_Name.Text,
                        Id:
                        LookUp(
                                  'SharePointList 1',
                                  'Component Name' = TextInput_Name.Text
                         ).ID
                  }
        }, Form_Attachments.Updates
)

 

Here I am patching a new item to 'SharePointList 1' and then patching to 'SharePointList 2' using a Form in 'New' mode. In the second patch the 'Component Name' is searched for in 'SharePointList 1' and then used as the Component Name in 'SharePointList 2'. I had to do it this way as 'Component Name' is a lookup column that connects both lists.

 

My problem - After doing some research I realised that patching an Attachment to SP could be tricky. So, I followed the online advice and created a separate Form with just the Attachment property in it. I then referenced the Form in the Submit button above (Form_Attachments.Updates). but I keep getting an error saying that there is a Patch error and that the 'Component Name' is required. I guess this is because it doesn't know where to place the attachment as I am not referring to the specific item I would like to patch the attachment to.

 

I would appreciate if someone could help me with adding an attachment to a SPL when using a 'New' Form and when the target list has a required column that is of type Lookup to another list. Hope I've explained that ok.

 

Regards

Categories:
I have the same question (0)
  • Michael E. Gernaey Profile Picture
    53,932 Moderator on at

    @Marty3012 

     

    Hi Marty,

     

    If I might first say, looking at this statement, I do not see the Default('SharePointList 1') required for patching a new record. Is this maybe just a typo in what you shared? And is why it may not be finding it and failing the second patch.

     

     

     

    Patch(
     'SharePointList 1',
     {
     'Component Type': ComboBox_Type.Selected,
     'Component Name': TextInput_Name.Text
     }
    );

     

     

     

    Patch(
     'SharePointList 1',Defaults('SharePointList 1'),
     {
     'Component Type': ComboBox_Type.Selected,
     'Component Name': TextInput_Name.Text
     }
    );​

     

     

    Also for your second patch, I do not see a LookUp to the record you want to patch (or is this a create?)


    If you like my answer, I would really appreciate if you please Mark it as Resolved, and give it a thumbs up, so it can help others

    Cheers

    Thank You
    Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
    https://gernaeysoftware.com
    LinkedIn: https://www.linkedin.com/in/michaelgernaey

     

  • Marty3012 Profile Picture
    on at

    HI @FLMike ,

     

    I included the defaults() function in the patch but get the same error. I am creating a record in the SPL and I think you are correct, I will need some kind of look up to find the record I've just created. 

     

    In the first patch I create a record in 'SharePointList 1' and then in the second patch I look up 'SharePointList 1' to find 'Component Name' and then use this name as a value in 'SharePointList 2' column 'Component Name'. This is because the 'Component Name' column in 'SharePointList 2' is a look up column. The above all works without the attachments included. Would I need a separate patch for the Attachment?

     

    Apologies as I'm struggling to explain this right.

     

    Thanks

  • Verified answer
    Marty3012 Profile Picture
    on at

    Hi @FLMike - I really struggled to get it to work so I used Flow instead. I have almost got that working but need a bit of help with the last part of it, so I'm going to start another thread as its quite different to the original question. Thanks

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 93 Most Valuable Professional

#2
Haque Profile Picture

Haque 81

#3
Valantis Profile Picture

Valantis 49

Last 30 days Overall leaderboard