Hello, Tony!
Don't get discouraged, as this dynamic filtering can sometimes be tricky to implement. Different fields use different methods, sometimes you miss some important step, etc. But it's more than possible to implement in your case, it can actually get much more complex than that.
So, what you need to do, is follow the article closely to make sure you haven't missed any step. Also, make sure to remove any other filtering from Related Items for now, so it doesn't interfere with the code. I also recommend replacing code with something like this, so you can show us your console output with logs and errors if there are any:
Code: Select all
// Calling Functions on Form Load
setHash();
fd.field('Contact_x0020_Name').change(function(){
setHash();
});
// Function to filter and refresh Related Items Viewer
function setHash(){
console.log("Setting Hash...");
var value = fd.field('Contact_x0020_Name').value();
if (value == '') {
value = 0;
}
console.log("Contact: " + value);
value = encodeURIComponent(escape(value)).replace(/\-/g, "%252D");
//set the URL’s hash value.
window.location.hash = "InplviewHash" + $(".relatedIssues [webpartid]").attr("webpartid") + '=FilterField=ID-FilterValue=' + value;
}
Finally, if this doesn't help, I recommend commenting out all the code and filtering Related Items manually first. You can do it by clicking small arrow near the column name and selecting values you want the column to be filtered by:

- Filters.png (7.8 KiB) Viewed 2811 times
Now, this will also add a hash in a similar way as what we are trying to do. You can check the hash in the URL of the page after applying filtering, and you can use
this site to decode URL. You only need to check what it says in Filter field and Filter Value, other values are not too important in this case.
Make sure that you do NOT sort the column in ascending or descending order though! This will change the hash and it wouldn't be very useful.
Regarding getting the emails, it's more than possible to do. Here is an example code to loop through Related Items and get all the Titles:
Code: Select all
var rows = fd.relatedItems(0).data('ctx').ListData.Row;
for (var i = 0; i < rows.length; i++) {
alert(rows[i].Title);
}
It iterates through the first Related Items control on the form, hence fd.relatedItems(
0)... But you can use CSS class to access the specific Related Items control you need instead.