Page 1 of 1

Edit related items in regular mode

Posted: 02 Jun 2017
by TWendt
Hi,
i can add items when i create a new entry in my list. But if i open the entry in the edit mode, i can add an item but it is not displayed.
Please help.

Best regards
Tom

Re: Edit related items in regular mode

Posted: 05 Jun 2017
by Dmitry Kozlov
Please, read the following article ('Edit and Display forms' section):
https://spform.com/documentation/relate ... gular-mode

Re: Edit related items in regular mode

Posted: 06 Jun 2017
by TWendt
Hello Dmitry,

i don't understand this:

1. Navigate to the source list and add ID as an additional column of the lookup column pointing to the parent list:
List settings → Columns → Pick the lookup column → Add a column to show each of these additional fields → Pick the ID.

I can't add "ID" to my lookup column "Costs" because it's a standard column.

Best wishes
Tom

Re: Edit related items in regular mode

Posted: 06 Jun 2017
by Dmitry Kozlov
Open the column settings of the 'Costs' column and add ID as an additional column in the corresponding section. After that, a new column Costs:ID will be added to the list.

Re: Edit related items in regular mode

Posted: 06 Jun 2017
by TWendt
Hi Dmitry,

i added the ID of the parent list as an additional column. After that i change in the Data Source Editor from the field RelatedStakeholder to the filed Parent:ID. After that, if i open the form in the edit mode, no entries are displayed. If i change to the field RelatedStakeholder the entries which have been created over the new form are displayed.
What am i doing wrong?

Best wishes
Tom

Re: Edit related items in regular mode

Posted: 07 Jun 2017
by Dmitry Kozlov
Set 'Form field' to ID and 'List field' to Parent:ID in the Data Source Editor.

Re: Edit related items in regular mode

Posted: 07 Jun 2017
by TWendt
Hi Dmitry,

i create for a test three lists. One parent list "PCR" and two source lists "Kosten" und "Beratung". Then i create a new and a edit form.
In the new and edit form i added only these two entries in the javscript editor:

fd.populateFieldsInGrid($('.related-items'), {
  Costs: '{CurrentItem}',
});

fd.populateFieldsInGrid($('.related-guide'), {
  Guidance: '{CurrentItem}',
});

New Form: In the data source editor are the lists selected and under view "all elements".
Edit Form: In the data source editor are the lists selected and under view "Related-View". Filter by form field is "ID" and list field "Costs".

In the source list, for example "Kosten" i added in the JavaScript editor

if (window != window.top && window.top.fd) {
    // the form is opened in a dialog from the parent form
    var parentId = window.top.GetUrlKeyValue('ID');
    if (parentId) {
        // the form is opened from the Edit form
        fd.field('Costs').value(parentId);
    } else {
        // the form is opened from the New form
        $('#_fd_parent_temp > input').val(window.top.fd._tempParentId());
    }
     
    $('.parent-field').hide();
}

In the CSS Editor i added

fd.populateFieldsInGrid($('.parent-field'), {
  Costs: '{CurrentItem}',
});

And the HTML entry is

<div id="_fd_parent_temp">
<asp:HiddenField runat="server" ID="_fd_parent_tempField" __designer:bind="{ddwrt:DataBind('i','_fd_parent_tempField','Value','Load','ID',ddwrt:EscapeDelims(string(@ID)),'@_fd_parent_temp')}" />
</div>

Thats all. There is no column ID but I can create a new entry in the list and can add entries in the edit form without problems. But in the production form it is not possible to add entries in the edit form. I'll go crazy :-)

Best wishes
Tom

Re: Edit related items in regular mode

Posted: 08 Jun 2017
by TWendt
UPDATE:

Hi Dmitry,
i found an error. I added a line "fd.field('Telefon').value(parentId);". This field is filled with the ID from the parent list. The field RSH is not filled.


if (window != window.top && window.top.fd) {
    // the form is opened in a dialog from the parent form
    var parentId = window.top.GetUrlKeyValue('ID');
    if (parentId) {
        // the form is opened from the Edit form
        fd.field('RSH').value(parentId);
fd.field('Telefon').value(parentId);
    } else {
        // the form is opened from the New form
        $('#_fd_parent_temp > input').val(window.top.fd._tempParentId());
    }
     
    $('.rsh-field').hide();
}

Best wishes
Tom