I'm trying to dynamically filter the records that a Data View WebPart displays based on the return value of a javascript query. I would like some advice as to how I should do this or if it's even possible.
Basically, each user who logs into my company's SharePoint site has a "Department" number in their User Information. My javascript function successfully returns that value, but, now, I want my Data View to only display rows whose Department column matches the Department value returned by this function. I selected the "Filter Option" from the Options ribbon and added a simple filter to display only rows where the Department column was equal to 1. I replaced the '1' with my javascript function, and the result looked like this:
<Query>
<Where>
<Eq>
<FieldRef Name="NewColumn1"/>
<Value Type="Number">
<script type="text/javascript">
(function() {
var filter = [code to pull Department...];
return Number(filter);
})();
</script>
</Value>
</Eq>
</Where>
</Query>
Currently, no results are returned when the view is loaded.
My question is, is there a way to get this javascript function to work with the filter, or is this impossible to do? If it's not possible, are there any good alternatives to do what I am trying to do?