0

Good Morning!~

I have a button on a page that brings up the modal newform for a Questions and Answers list.

javascript:

var options=SP.UI.$create_DialogOptions();options.url='https://server/sites/collection/subsite/Lists/Questions Answers/NewForm.aspx?IsDlg=1';options.height = 400;void(SP.UI.ModalDialog.showModalDialog(options));

This works great...except it is on a template site. We need the url to be relative or possibly dynamically update when a new template is created (thinking way outside my box here)?

I've tried /lists, ../../lists, etc....and I am sure I am missing something as A) it is not working...and B) in my mind there is nothing linking it to the list???

Your expertise and time is GREATLY appreciated!~

1

For keeping the URL dynamic, you can use _sppagecontextinfo. Below is an example for your reference.

var url = _spPageContextInfo.webAbsoluteUrl + "/Lists/" + listTitle + "/NewForm.aspx";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.