Passing Multiple Choice values in Related Items

rss

Posted by metrovan - Feb 10 ’17 at 11:51

Hi,

I've set up a related items edit form. In my javascript I have:

fd.updateDroppedDocuments('.related-docs', {
Tags: fd.field('Tags').value(),
ShortDescription: fd.field('ShortDescription').value(),
Location: fd.field('Location').value(),
Photographer: fd.field('Photographer').value(),
Title: fd.field('Title').value()
});

I have 2 lists (a custom list, and a document library list), both have Tags with identical multiple choice values. I can pass over the Title, Location, Photographer fields over to document library fine, but Tags is blank and not checked.

 

How can I pass the Tags over to the document library list?

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 6 years 2 months 21 days
    #1 by Dmitry Kozlov Feb 13 ’17 at 03:17

    Hi,

    What's the type of Tags field? - Choice with checkboxes?

  • metrovan
    Member
    Member for: 2 years 9 months 29 days
    #2 by metrovan Feb 14 ’17 at 10:41

    Hi Dmitry,

    Yes, its choice with checkboxes.

     


  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 6 years 2 months 21 days
    #3 by Dmitry Kozlov Feb 15 ’17 at 02:59

    [#2]: Hi,

    Please, try this:

    fd.updateDroppedDocuments('.related-docs', {
    Tags: fd.field('Tags').control()._el()
    			.find('input:checked')
    			.map(function(){ return $(this).parent().find('label').text() })
    			.get()
    			.join('; '),
    ShortDescription: fd.field('ShortDescription').value(),
    Location: fd.field('Location').value(),
    Photographer: fd.field('Photographer').value(),
    Title: fd.field('Title').value()
    });
     
  • metrovan
    Member
    Member for: 2 years 9 months 29 days
    #4 by metrovan Feb 15 ’17 at 10:41

    Hi Dimitry,

    That worked, partially.

     

    The values are seen in the display form. Example: Beauty; Events

     

    But when I edit the item, nothing is checked in tags checkboxes.

     

     

  • metrovan
    Member
    Member for: 2 years 9 months 29 days
    #5 by metrovan Feb 15 ’17 at 10:48

    This is the display form of my related item, Tags have the correct values updated from the other list.

    Display form, tag values are updated over from another list

     

    When clicking on Edit, the Tags checkboxes are not selected.

     

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 6 years 2 months 21 days
    #6 by Dmitry Kozlov Feb 16 ’17 at 04:23

    [#5]: You're right, my mistake. The code must be:

    fd.updateDroppedDocuments('.related-docs', {
    Tags: fd.field('Tags').control()._el()
    			.find('input:checked')
    			.map(function(){ return $(this).parent().find('label').text() })
    			.get()
    			.join(';#'),
    ShortDescription: fd.field('ShortDescription').value(),
    Location: fd.field('Location').value(),
    Photographer: fd.field('Photographer').value(),
    Title: fd.field('Title').value()
    });
    

    Use ;# as a separator of the selected options.

  • metrovan
    Member
    Member for: 2 years 9 months 29 days
    #7 by metrovan Feb 16 ’17 at 10:46

    that works perfect. Thanks!

Displaying 1 to 7 of 7 messages