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?

  • Dmitry
    Dmitry
    Admin
    Member for: 11 years 3 months 13 days
    #1 by Dmitry Sep 5 ’13 at 02:07

    Hello Jeff,

    Please use the following js-code to open the specific New form of your related list and to pass additional parameters:

    // Put here the link to the specific New form and pass additional parameters ('test' in my case):
    var newFormUrl = '/sites/spform/Lists/Countries/NewForm.aspx?test=1';
    
    // 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;');
    
  • Hubbaroo
    Member
    Member for: 10 years 2 days
    #2 by Hubbaroo Sep 20 ’13 at 03:31

    [#1]: I have the parent form with the related items control workibng to create a related item in the child list. We need to set a choice field in the child form based on a selection on the parent form. So far I have tried using the information here but no luck.

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 10 years 1 day
    #3 by Dmitry Kozlov Sep 21 ’13 at 04:09

    [#2]: Hubbaroo, please, follow instructions from our article:
    http://formsdesigner.blogspot.com/2013/08/how-to-create-forms-with-related-items.html

  • Hubbaroo
    Member
    Member for: 10 years 2 days
    #4 by Hubbaroo Sep 23 ’13 at 05:57

    We have the related creating as expected but can't seem to get any other fields to populate on the related items form. Even if I try to set the value of a text field with the following, only the Company field get the ID, the Textfield gets nothing.

     

    var parentID = fd.getSourceID()
    fd.field('Textfield').control().value("Hello")
    if (parentID) {
    fd.field('Company').control().value(parentID);
    $('.company-field').hide();
    }

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 10 years 1 day
    #5 by Dmitry Kozlov Sep 24 ’13 at 08:43

    [#4]: Please, check if there are any javascript errors in your browser console. Make sure that 'Textfield' is internal name of your field.

  • Hubbaroo
    Member
    Member for: 10 years 2 days
    #6 by Hubbaroo Sep 24 ’13 at 10:37

    [#5]: I was using the wrong name. I looked up the internal name and now it works. Thank you.

  • Hubbaroo
    Member
    Member for: 10 years 2 days
    #7 by Hubbaroo Oct 8 ’13 at 05:43

    [#1]: If I wanted to pas a value from a field on the display form how would I referance that value. In the edit form I can set an alert to display the value but in the display form I jet get undifined returned???

  • Hubbaroo
    Member
    Member for: 10 years 2 days
    #8 by Hubbaroo Oct 8 ’13 at 06:01

    [#7]: This works on the edit form load but returns undefined on the display form load?? This is a choice field with 3 values.

     

    alert(fd.field('Catagory').control().value());

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 10 years 1 day
    #9 by Dmitry Kozlov Oct 9 ’13 at 03:42

    [#8]: To get value of the field in Display form, please, use the following code:

    fd.field('InternalName').control()._el().text()
    
  • Hubbaroo
    Member
    Member for: 10 years 2 days
    #10 by Hubbaroo Oct 9 ’13 at 12:23

    [#9]: Perfect. Thank you

Displaying 1 to 10 of 17 messages
Previous12