Passing Multiple Choice values in Related Items

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
metrovan
Posts: 16
Joined: Fri Feb 10, 2017

10 Feb 2017

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?

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

13 Feb 2017

Hi,

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

metrovan
Posts: 16
Joined: Fri Feb 10, 2017

14 Feb 2017

Hi Dmitry,

Yes, its choice with checkboxes.

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

15 Feb 2017

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

metrovan
Posts: 16
Joined: Fri Feb 10, 2017

15 Feb 2017

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
Posts: 16
Joined: Fri Feb 10, 2017

15 Feb 2017

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

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

16 Feb 2017

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.

metrovan
Posts: 16
Joined: Fri Feb 10, 2017

16 Feb 2017

that works perfect. Thanks!

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 5 guests