Page 1 of 1

Passing Multiple Choice values in Related Items

Posted: 10 Feb 2017
by metrovan
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?

Re: Passing Multiple Choice values in Related Items

Posted: 13 Feb 2017
by Dmitry Kozlov
Hi,

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

Re: Passing Multiple Choice values in Related Items

Posted: 14 Feb 2017
by metrovan
Hi Dmitry,

Yes, its choice with checkboxes.

Re: Passing Multiple Choice values in Related Items

Posted: 15 Feb 2017
by Dmitry Kozlov
Hi,

Please, try this:

Code: Select all

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()
});

Re: Passing Multiple Choice values in Related Items

Posted: 15 Feb 2017
by metrovan
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.

Re: Passing Multiple Choice values in Related Items

Posted: 15 Feb 2017
by metrovan
This is the display form of my related item, Tags have the correct values updated from the other list.
Image

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

Image

Re: Passing Multiple Choice values in Related Items

Posted: 16 Feb 2017
by Dmitry Kozlov
You're right, my mistake. The code must be:

Code: Select all

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.

Re: Passing Multiple Choice values in Related Items

Posted: 16 Feb 2017
by metrovan
that works perfect. Thanks!