SOLVED

How to render a link to the newform.aspx in SPFx?

%3CLINGO-SUB%20id%3D%22lingo-sub-665824%22%20slang%3D%22en-US%22%3EHow%20to%20render%20a%20link%20to%20the%20newform.aspx%20in%20SPFx%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-665824%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3EI%20have%20created%20a%20webpart%20that%20render%20the%20content%20of%20a%20list%20using%20the%20DetailList%20component.%3CBR%20%2F%3ENow%20I%20want%20to%20create%20a%20link%20to%20the%20NewForm.aspx%20so%20when%20a%20user%20click%20on%20it%20get%20sended%20to%20the%20new%20item%20form.%3C%2FP%3E%3CP%3EThe%20link%20needs%20to%20be%20dynamic.%20The%20webpart%20can%20be%20used%20with%20diferent%20lists%20so%20I%20can%C2%B4t%20hardcode%20the%20link.%3C%2FP%3E%3CP%3EHow%20can%20I%20do%20it%3F%3C%2FP%3E%3CP%3EBest%20regards%2C%3CBR%20%2F%3EAmerico%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-665824%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-686538%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20render%20a%20link%20to%20the%20newform.aspx%20in%20SPFx%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-686538%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F117034%22%20target%3D%22_blank%22%3E%40Americo%20Perez%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20can%20build%20the%20link%20like%20this%3A%3CBR%20%2F%3E%3CBR%20%2F%3Ehttps%3A%2F%2F%3CTENANT%3E.sharepoint.com%2Fsites%2F%3CSITE%3E%2F_layouts%2F15%2Flistform.aspx%3FPageType%3D8%26amp%3BListId%3D%3CLISTID%3E%26amp%3BRootFolder%3D%2Fsites%2F%3CSITE%3E%2F%3CLIST%20name%3D%22%22%3E%26amp%3BSource%3D%3CURL%20to%3D%22%22%20redirect%3D%22%22%20after%3D%22%22%20submit%3D%22%22%3E%3C%2FURL%3E%3C%2FLIST%3E%3C%2FSITE%3E%3C%2FLISTID%3E%3C%2FSITE%3E%3C%2FTENANT%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Regular Contributor

Hi,

I have created a webpart that render the content of a list using the DetailList component.
Now I want to create a link to the NewForm.aspx so when a user click on it get sended to the new item form.

The link needs to be dynamic. The webpart can be used with diferent lists so I can´t hardcode the link.

How can I do it?

Best regards,
Americo

1 Reply
Highlighted
Solution

@Americo Perez 

 

You can build the link like this:

https://<tenant>.sharepoint.com/sites/<site>/_layouts/15/listform.aspx?PageType=8&ListId=<listID>&RootFolder=/sites/<site>/<list name>&Source=<url to redirect after submit>