Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ListItemAttachments use when creating a new list item #363

Closed
chris-ci opened this issue Sep 8, 2019 · 10 comments
Closed

ListItemAttachments use when creating a new list item #363

chris-ci opened this issue Sep 8, 2019 · 10 comments
Labels
status:fixed Issue fixed in current or prior release. type:enhancement New feature or enhancement of existing capability

Comments

@chris-ci
Copy link

chris-ci commented Sep 8, 2019

Category

[ ] Enhancement

[ ] Bug

[X ] Question

Version

Please specify what version of the library you are using: [ 1.14.0 ]

Expected / Desired Behavior / Question

I am just learning the whole SPFx and am trying to enable a user to add attachments on my form which will create a new list item after they filled out the form and click the submit button. I just added the ListItemAttachments component and it is expecting the list item ID which doesn't exist yet. Is there any way to use this component before the list item is created and during/after creation add the attachments to the newly create list item?

Observed Behavior

I am using a state variable to save the new list item ID after creation which is 0 until the user clicks on the submit button.
When I load the webpart, I get an error "Error on load list item attachment, reason: Cannot read property 'map' of null"

Steps to Reproduce

Added below code to my tsx (listId redacted)

@ghost
Copy link

ghost commented Sep 8, 2019

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

@ghost ghost added the Needs: Triage 🔍 label Sep 8, 2019
@cardinalpipkin
Copy link

This would be very useful. I've struggled to get this working (still haven't) but yes it would be great to be able to test it without submitting?

@evlo
Copy link

evlo commented Nov 29, 2020

Hi, are there any plans to add this functionality?

@joelfmrodrigues
Copy link
Collaborator

Hi @chris-ci, cardinalpipkin and @evlo
Thanks for the suggestion, sounds like a great improvement.
I don't believe this is supported at the moment, but happy for someone to submit a PR with the improvements

@mgwojciech
Copy link

mgwojciech commented May 20, 2021

Would something like this be useful in that case:
image

In this example there is no itemId passed (id=0). Once You have id You can call the reference.current.uploadAttachments(1).
If You can think of a better approach, let me know.

In general, I can take this :)

@joelfmrodrigues
Copy link
Collaborator

@mgwojciech sounds like a way to get it to work, thanks for the suggestion. Would you be willing to submit a PR and also include an update to documentation? If so I will assign you to this issue so other people are aware that it's being addressed.

@mgwojciech
Copy link

@joelfmrodrigues - sure thing! I'm not sure if quality of the docs will be satisfactory but I'll do my best :)

@mgwojciech
Copy link

Pushed with my other PR:
#906

Have a great weekend

@joelfmrodrigues
Copy link
Collaborator

@mgwojciech Thanks, I'm sure it will be satisfactory :) All I was referring to was to add an example for the use case above so people understand how to use it when the item is yet to be created.
I will review as soon as possible

@joelfmrodrigues
Copy link
Collaborator

PR merged long ago, closing

@joelfmrodrigues joelfmrodrigues added status:fixed Issue fixed in current or prior release. and removed help wanted labels Aug 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:fixed Issue fixed in current or prior release. type:enhancement New feature or enhancement of existing capability
Projects
None yet
Development

No branches or pull requests

5 participants