Hide/Reveal series of Managed Metadata columns

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
Kris_NorthCarolina
Posts: 3
Joined: Fri Jul 28, 2017

30 Oct 2017

Hello,

I've tried figuring this out on my own without result so far. What I'd like to do is this. I have several columns where a user could enter information about the languages they know. The languages they choose come from a managed metadata source. For various reasons, each cell must be limited to one entry. This is why I have several of these fields in the SharePoint list. So I have fields called Langauge01, Language02, Language03, and so on to 08.

I don't want the form to fill up with blank options most users don't use, though. I want to create a kind of hide/reveal action on the form.

I've been trying to figure out the correct JavaScript code so that if Language01 is blank, the Language02 field is hidden. Then when someone makes a selection for Language01, the Language02 field appears. Language03 is hidden until Language 02 is no longer blank. And so on.

I can't get even one iteration of this to work, though. I think I'm missing some detail about coding for the managed metadata field type. Here's what I have:

function showfield_hide01() {
var Language01 = $.trim(fd.field('Language01').control()._el().find('.ms-taxonomy .valid-text').length == 0));
if (Language01 == "") {
$('.field_hide01').hide();
}
}

Any suggestions please? Thanks.

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

31 Oct 2017

Hello, Kris!
This is going to be quite a complicated JavaScript. You'll need to detect changes to Metadata to do it properly.
This is possible to do with the following code:

Code: Select all

var container = fd.field('InternalName').control()._el().find('.ms-taxonomy').get(0);
container.JavascriptOnValidation = "alert('Managed metadata changed!')"; 
But can you explain to us what exactly you want to achieve with the function? I understand that you don't want to show all 8 fields at the same time and only reveal them one by one, but that still opens many questions. For example, should the fields get hidden again if the fields before them no longer have a value?

Let's say user inputs Language1 and Language2 field shows up. User then inputs Language2 and Language3 shows up. What if user deletes language from Language1? Should Language2 be still visible? Or should it hide all the fields after Language1 and clear them of any metadata? Maybe something else?

If you can give us more information, we might be able to do this script for you. Basic version will probably take us 60 minutes of extra support time which you can buy in our store - https://spform.com/buy/support-maintenance If you'll need some additional functionality, like checking that every language on the form is unique or something else, that will probably take more time.

But if you want us to write the code for you, send a detailed request to support@spform.com and we'll see what we can do.
Cheers

Kris_NorthCarolina
Posts: 3
Joined: Fri Jul 28, 2017

31 Oct 2017

Hello Nikita!

Thanks for the response! I really enjoy your product and the support you and your team provide has been excellent.

So for this I'd be happy with a simpler solution than the one I described, which is simply the ideal scenario. I would like it structured so that if a user fills out language 2 and then changes their mind and deletes their entry, I don't need that to trigger a change so that language3 disappears again.

I wasn't sure whether this would require a complicated script or if I was just referring to the managed metadata data type incorrectly. Since you mention that this would be very complex to script, I may not pursue it, and instead just use the accordion or tab feature to minimize the space for the additional fields.

If you could answer one question, though: do columns that use the managed metadata data type need to be referenced in an unusual way in javascript? Thanks!

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

31 Oct 2017

Managed Metadata fields are quite complex in how they are handled and they are very different when it comes to JavaScript. If you can do something else instead, use it, it should be simpler.

If not and you really need the code, we can try to find a way for you, but that will take some time, though still should be doable.
Cheers

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 5 guests