I am trying to put custom JavaScript variable or function into the sharepoint's list view page, inside caml query, using sharepoint designer

for example:

i am opening list view i want to modify. than i am adding custom javascript code which will be executed on page load and i want to use value, returned from this function, inside caml query:

<View Name="{SOMENAME}" MobileView="TRUE" Type="HTML" DisplayName="MyGroups" Url="SOMEURL" Level="1" BaseViewID="2" ContentTypeID="0x" ImageUrl="/_layouts/15/images/issuelst.png?rev=23" >
                <FieldRef Name="ID" Ascending="FALSE"/>
                    <FieldRef Name="Group_x0020_Name"/>
                    <Value Type="Text">BPA</Value>
            <FieldRef Name="LinkTitle"/>
        <RowLimit Paged="TRUE">10</RowLimit>
        <Aggregations Value="Off"/>
        <XslLink Default="TRUE">main.xsl</XslLink>
        <Toolbar Type="Standard"/>

so i want to put variable or function here:

<FieldRef Name="Group_x0020_Name"/>

Is it possible?

I want to have listview based on currently logged in user's group, and since i want to get the currently logged in user's group name from custom list, not from the permission's group, i have no idea how to pass returned value from function executed during page.onload to the listview. The only solution i have found was to use HTML From Web Part, connect this form to my listview and then onload pass value as parameter to the form and trigger postback function. but since postback function trigers page reload, it falls into the endless loop (page load > form submission>page load>form submission..

  • No one can answer my question. Is it so hard to do? or impossible? Dont believe something is impossible :(
    – wol
    Dec 1, 2016 at 14:06
  • 1
    If you expect an answer within an hour, you are in the wrong place. Dec 1, 2016 at 15:13
  • OR how can parameter passed dynamically to list view with javascript without page reload?
    – wol
    Dec 1, 2016 at 16:04

2 Answers 2


Use standard SP2013 - CSR - Client Side Rendering to get your "group" info and display the View



Thanks for the replay. It is great article and big thanks to both of you. But what about i am tinkering right now is, can't remove extra items correctly from view. for exmaple:

(function() {
function listPreRender(renderCtx) {
    var rows = renderCtx.ListData.Row;
    var i = rows.length;
    while (i--) {
        var del = rows[i]['Group_x0020_Name'] === 'BPA';
        if (del) {
            rows.splice(rows[i], 1);
    renderCtx.ListData.LastRow = rows.length;
function registerListRenderer() {
    var context = {};
    context.Templates = {};
    context.OnPreRender = listPreRender;
ExecuteOrDelayUntilScriptLoaded(registerListRenderer, 'clienttemplates.js');

sometimes removes items from view sometimes no. And despite fact that no item is shown in view, column filter is still viewable. here is image link

  • Ask this as another question, it won't get much attention here. I havenever deleted rows like this, don't know what happens. The filter is still there because SP creates it, you have to remove it in the OnPostRender (when the DOM is created) OR built the whole View HTML yourself.. note you can include images with ![](url) Dec 2, 2016 at 7:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.