Binding current item ID to subforms doesn't work

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
User avatar
chris.cook
Posts: 20
Joined: Wed May 31, 2017

06 Jul 2017

Following this example here https://spform.com/documentation/relate ... gular-mode , if the related items forms are in a second layer of tab control (a tab control inside one tab of a form), I get the expected behaviour, except that the lookup field doesn't get hidden as it should be by this line of code

Code: Select all

$('.parent-field').hide();
I have confirmed that it works correctly inside a single layer of tab control.
Is there any changes which need to be made for this to work?

User avatar
chris.cook
Posts: 20
Joined: Wed May 31, 2017

06 Jul 2017

I've noticed the fd.getSourceID() function returns null for this form, while when loading a related item form from the 'top level', the ID is returned correctly. I'm guessing this is where the issue is.

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

06 Jul 2017

This particular bug we couldn't replicate while testing. I am also not sure about application of fd.getSourceID(), it's not used in the article once. Please, double check everything once again with the instruction, and if you still experience troubles, we'll need more info to solve this.

Screenshots of forms and code might help(as full as possible), just so we can double check everything, and potentially replicate the issue and resolve it.
Cheers

User avatar
chris.cook
Posts: 20
Joined: Wed May 31, 2017

07 Jul 2017

Thanks for the reply - I noticed I was using the script from the 'quick edit' version of that post - I'm surprised it was working at all before now!

User avatar
chris.cook
Posts: 20
Joined: Wed May 31, 2017

07 Jul 2017

Okay, I'm now getting a related but different problem. The field is getting hidden, but isn't getting set.

In the parent form, I have this code in the JS editor:

Code: Select all

bindSubformsToCurrentItem([
        ".job-placements",
        ".participation-during-initiative",
        ".work-experience-placements",
        ".initiative-activity-participation",
        ".participant-products-and-services-delivered",
		".participant-contact",
		".case-notes",
		".referrals"
    ]);
    
    ...
    
    function bindSubformsToCurrentItem(subformClassArray) {
    for (var i = 0; i < subformClassArray.length; i++) {
        fd.populateFieldsInGrid($(subformClassArray[i]), {  
            Participant: '{CurrentItem}',
        });
    }
}
Each class in the array is the class of a related items control. In each related item's form's JS editor, I have this.

Code: Select all

if (window != window.top && window.top.fd) {
    // the form is opened in a dialog from the parent form
    var participantId = window.top.GetUrlKeyValue('ID');
    if (participantId) {
        // the form is opened from the Edit form
        fd.field('Participant').value(participantId);
    } else {
        // the form is opened from the New form
        $('#_fd_parent_temp > input').val(window.top.fd._tempParentId());
    }
     
    $('.participant').hide();
}
Where "Participant" is the lookup field, and 'participant' is the class of the lookup field on the form.

I have attached screenshots of the structure of each form with relevant class names and Internal names visible.
Main form:
PrimaryForm.PNG
PrimaryForm.PNG (125.56 KiB) Viewed 2158 times
Job Placements - related item form:
JobPlacements.PNG
JobPlacements.PNG (118.64 KiB) Viewed 2158 times

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

07 Jul 2017

At the moment, I would advise to simplify your code and instead of trying to change multiple fields like ".job-placements", ".participation-during-initiative", ".work-experience-placements", etc. simply do one field according to instruction. First get it to work, then implement multiple fields, otherwise it's harder to say what exactly goes wrong.

Few other things - make sure HTML field has CDATA set to false, it is very important for code to execute correctly. Also, there is a difference in binding items from New Form and Edit Form. Edit Form binds new item as soon as you create it, but New Form only binds the items after you Save it. So, if you create a new item and don't save the form, the items will be created, but won't be bound, simply because there is nothing to bind them to.
Cheers

User avatar
chris.cook
Posts: 20
Joined: Wed May 31, 2017

07 Jul 2017

Thanks for the feedback. I have made sure CDATA is false for the HTML fields.

I did have it all working, and simply created the function to do the same thing on each item - this was also working as expected.
I could create new Participants (primary form) and create new related items using (what I now realise is) a mix between the two methods described for Quick Edit view and Standard view. When creating new related item from within a new Participant, the lookup field stays visible - I can deal with that. Saving then correctly edits all related items to point to the new item.

The issue only occurs when I nest the Tab Controls. It is very strange behaviour without a logical reason for the bug on the surface, but I have confirmed this my moving the nested tab control out such that the related items are just in a single tab control. It all works unless the related items are in a second level tab control.

I'll save the form and remove all JS relating to the binding and start again, see if I can spot my error.

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

07 Jul 2017

Please do and once you start encountering particular error post here the exact changes that you made. So, the code before when it was working and code after when the bug appeared.
Cheers

User avatar
chris.cook
Posts: 20
Joined: Wed May 31, 2017

09 Jul 2017

Hello.

I have created a new form set and stripped all fields off the primary form, and removed all JS and CSS from both forms. I followed the example very carefully, but currently when creating a related item from the edit or display forms, the link is not made (the related item's lookup is not set).

Here are screenshots of each area to ensure it is all configured as it should be:
Primary Form:
1.PNG
1.PNG (203.71 KiB) Viewed 2137 times
2.PNG
2.PNG (41.19 KiB) Viewed 2137 times
3.PNG
3.PNG (23.42 KiB) Viewed 2137 times
Related Item Form:
Last edited by chris.cook on 09 Jul 2017, edited 1 time in total.

User avatar
chris.cook
Posts: 20
Joined: Wed May 31, 2017

09 Jul 2017

5.PNG
5.PNG (213.96 KiB) Viewed 2136 times

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 3 guests