Related Items - Pass Additonal Information

rss

Posted by Jeff Childers - Sep 4 ’13 at 07:15

In the past, I have used your examples to highjack the "New" button in order to pass various parameters via query string to a subform.

 

Now that you have a related items element in SPFORM, could you provide an example of how to pass and then access addiitonal parameters beyond just the list item ID to the new item form?

  • Hubbaroo
    Member
    Member for: 8 years 4 months 2 days
    #11 by Hubbaroo Oct 9 ’13 at 12:44

    [#10]: With 1 Related Items in the parent form I use the following code to pass additional information to the child's new form.

    // Put here the link to the specific New form and pass additional parameters:
    var cat = fd.field('Catagory').control().value()
    var newFormUrl = '/sites/resources/Lists/Contacts/NewForm.aspx?Catagory=' + cat;

    // Next 3 lines are required to open form in a dialog.
    var uri = new URI(newFormUrl);
    var url = uri.getLastPathSegment();
    g_useDialogAlwaysList.push(url.toLowerCase());

    // Here we replace the standard 'New item' link with our custom link:
    $('.ms-list-addnew a').attr('onclick', 'NewItem2(event, "' + newFormUrl + '");return false;');

     

    How would this work if we had a second, third or more Related Items and wanted to pass additional parameters? Help me understand how to detirmine what "Add new" was clicked from what Related Item.

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 8 years 4 months 2 days
    #12 by Dmitry Kozlov Oct 11 ’13 at 12:44

    [#11]: Hello,

    You can select the specific one 'New link' by its index:

    $('.ms-list-addnew a').eq(1).attr('onclick', 'NewItem2(event, "' + newFormUrl + '");return false;');
Displaying 11 to 12 of 12 messages