Get taxonomy field value label

Hi all,
I was wondering the best approach to get a field value in Plumsail form when this field is a taxonomy type. fd.field('myfield').value work for classic fields but not for taxonomy (it return a strange object).
fd.field('myfield') returns a big object with a lot of attributes. I have looked into the $el attribute but did not manage to find the field value label.
Does anybody have an idea ?

David

Dear @David74000,
For a single value taxonomy, please, try the following code:

// returns the name of the selected option
fd.field('Taxonomy').value.name;

// returns the ID of the selected option
fd.field('Taxonomy').value.id; 

Refer to our docs for more information on how to work with fields - https://plumsail.com/docs/forms-sp/javascript/fields-sp.html#managed-metadata-taxonomy-single

Thank you @Nikita_Kurguzov !

Hi again,
do you know what is the best approach to execute operation with termstore and taxonomy field inside a plumsail forms ?
In other tools i used the following function in order to do that:
SP.Taxonomy.TaxonomySession.getTaxonomySession(clientContext)

Do you know how can I get the SP object defined inside plumsail ? Or is there a better way to get for instance parent of a term, or other operation in taxonomy store ?
David

Dear @David74000,
No, the SP object is not available in Plumsail Forms as we do not load these scripts, though they can still be manually added to the form.

But the recommended way is to use the Graph API. Put this into JavaScript editor:

var ts = new GraphQueryable(graph, "termStore/groups");
ts.setEndpoint("beta");
ts.get().then(function(groups){ console.log(groups); });

For more info and a complete set of action, please, look here - https://docs.microsoft.com/en-us/graph/api/resources/termstore-store?view=graph-rest-beta

Thank you @Nikita_Kurguzov, unfortunately I am on prem SP2019 :frowning:.
In any case someone else having the same question, I used the taxonomy API TaxonomyInternalService.json.
Here is an example:

$.ajax({
				url:_spPageContextInfo.webServerRelativeUrl +"/_vti_bin/TaxonomyInternalService.json/GetCustomProperties",
				type:"POST",
				headers: {
				 "accept":"application/json;odata.metadata=minimal",
				 "content-type": "application/json;charset=utf-8",
				 "odata-version":"4.0",
				 "X-RequestDigest": formdigest
				 },
				data:'{"sspId":"0b5a7901def842b5b4706755ee189f25","lcid":1033,"webId":"00000000-0000-0000-0000-000000000000","listId":"00000000-0000-0000-0000-000000000000","termSetId":"'+termsetid+'","termId":"'+idTerm+'"}',
				success:function(data){
					var customPropsArray = data.d.Content;
					for (var i=0; i < customPropsArray.length;i++){
						var jsonobj = JSON.parse(customPropsArray[i]);
						mycustprop= jsonobj.MYCUSTOMPROPERTY;
						if (mycustprop) {
							break
						}
					}
					resolve(mycustprop);
				},
				error: function(err) {
					reject(err) // Reject the promise and go to catch()
				  }
			})

Dear @David74000,
I see! That's an excellent solution, thank you for it, I'm sure it will help many people with the same question - I might even use it myself if someone else has this question!