1

I've this code below:

function ReceivePages(FirstFolderProd, FirstFolderWithoutSpaceProd, GetTagFolder){ var restUrl = "https://tenant.sharepoint.com/sites/site/Negocio/OfertaParticulares/_api/web/lists/GetByTitle('2 - Produtos - Páginas')/GetItems(query=@v1)?@v1=" + "{\"ViewXml\":\"<View Scope='RecursiveAll'><Query><Where><And><Eq><FieldRef Name='ContentType' /><Value Type='Computed'>Produto</Value></Eq><And><Eq><FieldRef Name='Intranet_SubCategoria' /><Value Type='TaxonomyFieldTypeMulti'>"+GetTagFolder+"</Value></Eq><And><Eq><FieldRef Name='OfertaEmComercializa_x00e7__x00e3_o' /><Value Type='Boolean'>1</Value></Eq><Eq><FieldRef Name='_ModerationStatus' /><Value Type='ModStat'>0</Value></Eq></And></And></And></Where></Query></View>\"}"; jQuery.ajax({ url: restUrl, async: false, method: "POST", headers: { "Accept": "application/json; odata=verbose", "X-RequestDigest": document.getElementById("__REQUESTDIGEST").value, }, success: function (data) { var dataresult = data.d.results; dataresult = [].slice.call(dataresult); dataresult.forEach(function (key, value) { var SubTabs = (key.SubFamiliaParticulares.results["0"].Label); var SubTabsWithoutSpace = SubTabs.replace(/[^a-z0-9\s]/gi, '').replace(/[_\s]/g, ''); }); }, error: function (error) { console.log(error); } }); } 

My List Page: enter image description here

Grupo de Produtos is a taxonomy field (internal name SubFamiliaParticulares), how can I retrive unique values from that column? I already tried using GroupBy but didn't work.

Any idea?

    1 Answer 1

    0

    Per my knowledge, CAML query schema can't provide a way to get the unique values.

    As a workaround, we can use JavaScript to get unique values from an array object.

    The example code below for your reference.

    var data = [{"name":"Lenovo Thinkpad 41A4298","website":"google"}, {"name":"Lenovo Thinkpad 41A2222","website":"google"}, {"name":"Lenovo Thinkpad 41Awww33","website":"yahoo"}, {"name":"Lenovo Thinkpad 41A424448","website":"google"}, {"name":"Lenovo Thinkpad 41A429rr8","website":"ebay"}, {"name":"Lenovo Thinkpad 41A429ff8","website":"ebay"}, {"name":"Lenovo Thinkpad 41A429ss8","website":"rediff"}, {"name":"Lenovo Thinkpad 41A429sg8","website":"yahoo"}]; var uniqueNames = []; for(i = 0; i< data.length; i++){ if(uniqueNames.indexOf(data[i].website) === -1){ uniqueNames.push(data[i].website); } } for(i = 0; i< uniqueNames.length; i++){ alert(uniqueNames[i]); } 

    Refer to: JavaScript Array Distinct()

      Start asking to get answers

      Find the answer to your question by asking.

      Ask question

      Explore related questions

      See similar questions with these tags.