Page 1 of 1

Mandatory Related Item

Posted: 29 May 2017
by enillrae
Hello,

I currently have a form in which has two sets of related items in quick edit mode. Is it possible to make it mandatory? I

Thank you

Re: Mandatory Related Item

Posted: 30 May 2017
by Dmitry Kozlov
Hi,
Please, read the thread:
viewtopic.php?f=1&t=633

Re: Mandatory Related Item

Posted: 02 Jun 2017
by enillrae
Hi Dmitry,

I'm sorry I'm new to javascript.

can you explain how it would work in the "on submit". My related item is on another tab. When I added the code you suggested, the tabs are not displayed correctly to the top.

Re: Mandatory Related Item

Posted: 05 Jun 2017
by Dmitry Kozlov
Hi,
Do you mean that you want to activate a tab containing the Related Items control if a user left it empty? Then, please, use the code below:

Code: Select all

fd.onsubmit(function() {
    if (fd.relatedItems(0).data('ctx').ListData.Row.length == 0) {
        alert('Please, add related items');
        fd.tabControl(0).tabs('option', 'active', 1);
        return false;
    }
    
    return true;
})
Replace (1) in the line: fd.tabControl(0).tabs('option', 'active', 1); with 0-based index of the tab containing the related items.