Page 1 of 1

two related item child

Posted: 28 Sep 2018
by esit2018
Hi,

I have two related item child with refresh, but I can only refresh one of the related item child. I have a lookup field named Maquina, it's a parent. And two related item child, one is a horquilla list an the other is a bombas list. I want refresh the two child list when I select a Maquina in the lookup field. This is my javascript code:
//first filter on page load
setHashhorquilla();
setHashbomba();
//and attach an on-change handler that will call the filtering function wherever the value of the field changes
fd.field('Maquina').control().change(function() {
setHashhorquilla();
setHashbomba();
});

//this is the actual function that filters the list
function setHashhorquilla(){
//get value
var value = fd.field('Maquina').value();
//alert("Maquina"+value);
if (value == "(None)") {
value = "";
}
value = encodeURIComponent(escape(value)).replace(/\-/g, "%252D");
//set the URL’s hash value. An explanation on this is at the end of the article.
window.location.hash = "InplviewHash" + $(".related-horquilla [webpartid]").attr("webpartid") + '=FilterField=Modelo_x003a_ID-FilterValue=' + value;
}
function setHashbomba(){
//get value
var value = fd.field('Maquina').value();
//alert("Maquina"+value);
if (value == "(None)") {
value = "";
}
value = encodeURIComponent(escape(value)).replace(/\-/g, "%252D");
//set the URL’s hash value. An explanation on this is at the end of the article.
window.location.hash = "InplviewHash" + $(".related-bomba [webpartid]").attr("webpartid") + '=FilterField=Modelo_x003a_ID-FilterValue=' + value;
}

Thanks for your help.
Ruben

Re: two related item child

Posted: 01 Oct 2018
by AlexZver
Hi!

You just need to implement minor changes in function setHashbomba():

Code: Select all

function setHashbomba(){
    //get value
    var value = fd.field('Maquina').value();
    //alert("Maquina"+value);
    if (value == "(None)") {
        value = "";
    }
    value = encodeURIComponent(escape(value)).replace(/\-/g, "%252D");
    //set the URL’s hash value. An explanation on this is at the end of the article.
    var hash = window.location.hash;
    window.location.hash = hash + "#InplviewHash" + $(".related-bomba [webpartid]").attr("webpartid") + '=FilterField=Modelo_x003a_ID-FilterValue=' + value;
}

Re: two related item child

Posted: 01 Oct 2018
by esit2018
Many thanks. The code run perfectly.

Ruben Cayuelas