SOLVED

Using ListItemAttachments (pnp) - I don't know how to use it!

%3CLINGO-SUB%20id%3D%22lingo-sub-1114655%22%20slang%3D%22en-US%22%3EUsing%20ListItemAttachments%20(pnp)%20-%20I%20don't%20know%20how%20to%20use%20it!%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1114655%22%20slang%3D%22en-US%22%3E%3CP%3EI%20need%20to%20make%20a%20file%20upload%20to%20an%20SPO%20list%20for%20an%20SPFX%20web%20part%20form%20I'm%20making.%3C%2FP%3E%3CP%3EI've%20put%20this%20into%20my%20JSX%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%3CLISTITEMATTACHMENTS%20listid%3D%2223083058-4496-4367-9692-0c6fc430cce0%22%20itemid%3D%22%7B1%7D%22%20context%3D%22%7Bthis.props.context%7D%22%20disabled%3D%22%7Bfalse%7D%22%3E%3C%2FLISTITEMATTACHMENTS%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHow%20do%20you%20use%20it%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1117087%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20ListItemAttachments%20(pnp)%20-%20I%20don't%20know%20how%20to%20use%20it!%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1117087%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F142793%22%20target%3D%22_blank%22%3E%40Thomas%20Pipkin%3C%2FA%3E%26nbsp%3BThe%20control%20works%20under%20the%20assumption%20that%20an%20item%20has%20been%20created%20already.%20You%20would%20need%20to%20create%20an%20item%20first%2Cand%20pass%20that%20ID%20to%20the%20ListItemAttachments%20control.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Contributor

I need to make a file upload to an SPO list for an SPFX web part form I'm making.

I've put this into my JSX:

 

<ListItemAttachments listId='23083058-4496-4367-9692-0c6fc430cce0'
                     itemId={1}
                     context={this.props.context}
                     disabled={false} 
                     
                     />

 

 

How do you use it? I understand that this may be something that lists existing attachments, so in my case, because the form hasn't submitted anything yet, the item doesn't exist to hold an item. Despite that, my form allows clicking on existing items, WITH ATTACHMENTS, but still doesn't work and gives the same error when I go to the page with the ListItemAttachments field.

Is there anything that I can use for just a simple upload attachment folder that will show the existing attachment when a user opens up and existing item?

 

1 Reply
best response confirmed by Cardinal_Night (Contributor)
Solution

@Cardinal_Night The control works under the assumption that an item has been created already. You would need to create an item first,and pass that ID to the ListItemAttachments control.