Passing Multiple Choice values in Related Items
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 KozlovAdminMember for: 9 years 8 months 7 days
Hi,
What's the type of Tags field? - Choice with checkboxes?
-
metrovanMemberMember for: 6 years 3 months 17 days
Hi Dmitry,
Yes, its choice with checkboxes.
-
Dmitry KozlovAdminMember for: 9 years 8 months 7 days
[#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() });
-
metrovanMemberMember for: 6 years 3 months 17 days
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.
-
metrovanMemberMember for: 6 years 3 months 17 days
This is the display form of my related item, Tags have the correct values updated from the other list.
When clicking on Edit, the Tags checkboxes are not selected.
-
Dmitry KozlovAdminMember for: 9 years 8 months 7 days
[#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.
-
metrovanMemberMember for: 6 years 3 months 17 days
that works perfect. Thanks!