Open different form for different list view in single form for using 'List or Library' control

Hello Community,
I am using two 'Lists or Library' control in my single form.
I have two different list views for a form that i want to use 'List or Library' control, so I use these two views for two 'List or Library' control.
My problem is when I try to create a new item it will show form for view1 for both views.

So, is there any way that i can achieve this,
or any other way I can redirect form according to the list view?

Thanks in Advance.

Hello @harshp924,

Do you want to display two different list views on the form?

You can show/hide the control dynamically using the code. For this:

  1. give a CSS class to the control, e.g. billing-info.

  2. add this code to JavaScript editor to hide/show control

//show control
//hide control

Or do you want to open different form sets?

Then you can set up a custom routing to redirect user to a specific form set. You can find more information about routing here.

Hello @mnikitina,
Yes i want to set up custom routing
Let's say I have one Child list name 'Employee', that contains some columns for personal information like 'FirstName', 'LastName' etc, and some columns that help to store data for organization use like 'Salary', 'Hours', 'Position' etc.

So i have to use two list or library control one for personal information and other for organization data.
So I create two list view View1 (for Firstname, lastname) and View2 (salary, hours).
in child list i want two different form respectively to these two list or library control.
i am looking for routing child list form according to view, so i can redirect the user to form for 'Personal Information' and 'Data for Organization'.

I hope you get my point,

Hello @harshp924,

You can use the code below to open the corresponding form set from List or Library control.

Please add this code to JavaScript Editor >> Current Form section in the parent form:

function selectFormSet(dt, formSetId) {
    var funcName = dt._listViewManager.openDialogFuncName;
    var func = window[funcName];
    window[funcName] = function(url, pageType) {
        window.FormSet = formSetId;
        func(url, pageType);
fd.spRendered(function() {
    fd.control('SPDataTable1').ready().then(function(dt) {
        //replace with the Forms Set ID for view 1
        selectFormSet(dt, 'df788428-cab9-41f4-8583-4ab8b41e0a28');
    fd.control('SPDataTable2').ready().then(function(dt) {
         //replace with the Forms Set ID for view 2
        selectFormSet(dt, '27f0b45a-f904-42d4-b28e-f37d581e36f6');

Please add this code to the JavaScript Editor >> Custom Routing section in the child form:

    return window.parent.FormSet;

Thanks @mnikitina,
I will look into this.

1 Like

Hello, @mnikitina,
Above code works perfectly,

I want achieve something like rout list or library according to currant users language.
i have list or library same as above, in child form i created two different form set for different language.
so in parent form while English user try to open form, in child he could see english form and other language person can see their relative form.

How can i achieve the same..?

Thanks in Advance...!

Hello @harshp924,

You can set up routing between different forms based on the user's language. Please see Create forms in multiple languages article for more details.

Hello @mnikitina,
I was use routing based on current users language in parent form already, but I want that list or library control also should open forms for different languages.
How can I do that?


You can set up the same routing for the child form too.