SOLVED

SPFx : This is really weird, can't create new items when app is installed!

Highlighted
Regular Contributor

Hi,

 

I have created a web part and meanwhile I was testing it in workbench I was available to create new items from the web part. But when I deploy and install the app in Sharepoint online I can't create new items. 

 

The webpart is reading from the list and showing the items. 

But when I try to create a new item from the webpart, no new item gets created. 

I can't any error in the console. 

 

What can be the problem? 

 

Best regards

 

 

2 Replies
Highlighted
Best Response confirmed by Americo Perez (Regular Contributor)
Solution
Hi Americo

Open the developer tools in the browser and go to the network tab (this is the name in chrome, not sure about edge).
In there, check what happens with the post request when you try to create the items. The response information should have some error details.
You should also be able to capture the error in code. Are you running the code inside a try catch?

Hope that helps
Highlighted

Thanks for the tips. 

I found that the problem was how I was using the pnp addItem(). 

I followed this sample: Add items but for some reason it did'nt worked. 

So I found this other code that implement a create method and it did work: Pnp CRUD

 

I don't know what is the difference exactly  but in my eyes they are very similar. 

 

Thanks,

Best regard

Americo