0

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

Americo Perez
  • 95
  • 1
  • 4
  • 17

1 Answers1

1

You could use pnpJs to get list form url, sample code for your reference.

sp.web.lists.getByTitle("MyList3").forms.select().filter("FormType eq 8").get().then((item: any) => {
      console.log(item[0].ServerRelativeUrl);
    });

enter image description here

Lee
  • 5,305
  • 1
  • 6
  • 12