Different Form Set on Add New Item

Hello,

Is it possible to change the Form Set used when clicking the Add New Item button from a List or Library control. We have a scenario where we already have a default New form, but we would like to open a different version when creating an item from a List or Library Control on a certain Form.

Is it possible please?

Hello @Tony_Duke,

You can check the URL of the parent form and redirect users to a specific form set using Custom Routing

To get the URL of the parent form from the child form opened in the dialog you first need to define fd globally in the parent form with the code:

window.fd = fd;

And then you can get the URL with the following code:

window.top.location.href

Hi @mnikitina.

Can you provide us what the default "Add new item" button onclick url is so that we can subsequently change it correctly to load a custom form set instead of the default new form set dialog of the child list/library control please?

Thank you,
Stormanh

Hello @stormanh,

The routing works when the item is opened in the dialog from List or Library control. For instance, you can use this code in Custom Routing to check whether the form is opened in the dialog and rout to a specific form set.

if (window != window.top) {
    //replace with your form set ID
    return '542df351-ea25-49d1-9f46-aef786ffdeb3';
}

The default path to the new form is this:
{Sie URL}/SitePages/PlumsailForms/{ListName}/{Content Type Name}/NewForm.aspx

Thank you very much @mnikitina
It works! Just need to remove the extra ) in your provided code just in case someone is simply copying and pasting and wonders why it may not work after doing so... :grinning:

if (window != window.top) {
//replace with your form set ID
return '542df351-ea25-49d1-9f46-aef786ffdeb3';
}

1 Like

Hi @mnikitina.

Is there a way in custom routing or in the JS editor in the parent form to prioritize loading the form set with the above supplied code? I have other form sets in the same list that uses the out of the box check whether the current user is part of a SharePoint group and redirects them to a particular form set. How can I order the priority of which form set gets used? In other words, I would like the

if (window != window.top) {
//replace with your form set ID
return '542df351-ea25-49d1-9f46-aef786ffdeb3';
}

to take priority over the form sets that are based on which SharePoint group the user belongs to only when the "Add new item" button is clicked on for the child list/library control hosted in the parent form.

Thanks
Stormanh

Hello @stormanh,

Thank you for pointing at the typo, probably I wanted to add a smile)

Yes, you can specify the order in which to open Form Sets if conditions are met. The lower the Order value, the higher the priority for Form Set to open.