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: 8 years 7 months 26 days
Hi,
What's the type of Tags field? - Choice with checkboxes?
-
metrovanMemberMember for: 5 years 3 months 6 days
Hi Dmitry,
Yes, its choice with checkboxes.
-
Dmitry KozlovAdminMember for: 8 years 7 months 26 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: 5 years 3 months 6 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: 5 years 3 months 6 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: 8 years 7 months 26 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: 5 years 3 months 6 days
that works perfect. Thanks!