List/Library toolbar > Button to open up New form for specific Content Type

I have a SP List with two content types (Individual and Organization). I am not using the Item content type.

On a form page I have placed a Tab Control, and in each Tab I have a List/Library Control and set the view. The SP views only display columns specific to each content type, so effectively each tab is only a list of that specific content type.

I have hidden the standard “New” button on each List/Library Control since it has a dropdown to select the content type to create. However, I don’t want that functionality and instead have opted to create a new button for each List/Library under the separate tabs. The first button I want to open the New form in a dialog for the Individual content type (“Add Individual”), and the second button I want to open the New form in dialog for the Organization content type (“Add Organization”).

I am not entirely sure how to go about this. Any help is appreciated.

I have gotten this to work using:

let addIndividual = {
        text: 'Add Individual',
        class: 'btn-primary',
        visible: true,
        icon: 'AddFriend',
        iconType: 0,
        location: 0,
        click: () => {
            const listId = '[My List ID]';
            Dialog.open('[My Site]/_layouts/15/listform.aspx?PageType=8&ListId=' + listId, {
                passedStatus: 'New'
            }, result => {
                if (result) {
                    alert('Individual saved.');
                } else {
                    alert('No new Individual was created.');
                }
            }, {
                width: 1000,
                height: 1000,
                title: 'New Individual'
            });            
        }
    };

I will follow up if I have any more questions.

2 Likes