Confusion with related items

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
User avatar
Alexey Babin
Posts: 23
Joined: Wed May 11, 2016
Contact:

18 Aug 2016

I've faced to such problem: I'm using related items list in non-grid mode. And I need to be able to add new children on NEW parent's form (for new parent) and on EDIT parent's form (for existing parent). The parent's ID translation from Parens form provided by JS code on children's NEW form. The code is


$('#_fd_parent_temp > input').val(window.top.fd._tempParentId()); //This part for create new item from NEW parent
//this code for create new child for existing item via EDIT form.

var parentID = fd.getSourceID();
if (parentID) {
fd.field('ParentId').control().value(parentID);
}


So the problem is in ListView of related items, that is placed at Parent's NEW form. It appears when: 1. I create new parent (a.e. with ID = 1) (with or without children - at this moment it does not make sense) 2. I open existing parent (with ID = 1) 3. I add another children to this parent, save it, and close Edit form 4. I open new parent form, and see on the blank form previously created children (that has ParentID = 1) 5. ParentID of children described in previous point changes to 1. This probem disappear when I clear browser cookies after editing parent item, but it's not the case for users.

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

19 Aug 2016

Hi Alex,

Try to add the condition into the child form:

Code: Select all

if (window.top.fd._formType() == 'New') {
    $('#_fd_parent_temp > input').val(window.top.fd._tempParentId());
} else {
    var parentID = fd.getSourceID();
    if (parentID) {
        fd.field('ParentId').control().value(parentID);
    }
}

User avatar
Alexey Babin
Posts: 23
Joined: Wed May 11, 2016
Contact:

19 Aug 2016

Thanks a lot! Now works great!

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 7 guests