Custom Report - Table problem

Could you please tell me what is wrong in the relevance below
:

 var relevance = '(html "<table id=%22resultsTable%22 class=%22sortable%22><th>Patch Name</th><th>Number of reported computers</th><th>Count of installed</th><th>Pending Restart</th><th>Running</th><th>Not Relevant</th><th>Pending Downloads</th><th>Waiting</th><th>Evaluating</th><th>Locked</th><th>Download Failed</th><th>Offline</th><th>Expired</th><th>error</th><th>Failed</th>" & it & html "</table>") of concatenations of trs of (td of ( name of it as string ) & td of ((number of elements of reported computer set of it) as string) & td of (sum of number  of (statuses of results of it as string) whose (it contains "Fixed")) & td of (sum of number of (statuses of results of it as string) whose (it contains "Pending Restart")) & td of (sum of number  of (statuses of results of it as string) whose (it contains "Running")) & td of (sum of number  of (statuses of results of it as string) whose (it contains "Not Relevant")) &  td of (sum of number  of (statuses of results of it as string) whose (it contains "Pending Download")) &  td of (sum of number  of (statuses of results of it as string) whose (it contains "Waiting")) &  td of (sum of number  of (statuses of results of it as string) whose (it contains "Evaluating")) &  td of (sum of number  of (statuses of results of it as string) whose (it contains "Locked")) & td of (sum of number  of (statuses of results of it as string) whose (it contains "Download Failed")) & td of (sum of number  of (statuses of results of it as string) whose (it contains "Offline")) & td of (sum of number  of (statuses of results of it as string) whose (it contains "Expired")) &  td of (sum of number  of (statuses of results of it as string) whose (it contains "<error>")) &  td of (sum of number  of (statuses of results of it as string) whose (it contains "Failed")) ) of member actions of bes action whose (name of it = "' + actionName.value + '")';    

I modified WebReports - Search with DropList report from BES Session Relevance Tester Examples, but it does not show anything.

The statement you have looks like this:

 (html "<table id=%22resultsTable%22 class=%22sortable%22><th>Patch Name</th><th>Number of reported computers</th><th>Count of installed</th><th>Pending Restart</th><th>Running</th><th>Not Relevant</th><th>Pending Downloads</th><th>Waiting</th><th>Evaluating</th><th>Locked</th><th>Download Failed</th><th>Offline</th><th>Expired</th><th>error</th><th>Failed</th>" & it & html "</table>") 
of concatenations of trs of 
(
    td of ( name of it as string ) & 
    td of ((number of elements of reported computer set of it) as string) & 
    td of (sum of number of (statuses of results of it as string) whose ( it contains "Fixed")) & 
    td of (sum of number of (statuses of results of it as string) whose (it contains "Pending Restart")) & 
    td of (sum of number of (statuses of results of it as string) whose (it contains "Running")) & 
    td of (sum of number of (statuses of results of it as string) whose (it contains "Not Relevant")) &  
    td of (sum of number of (statuses of results of it as string) whose (it contains "Pending Download")) &  
    td of (sum of number of (statuses of results of it as string) whose (it contains "Waiting")) &  
    td of (sum of number of (statuses of results of it as string) whose (it contains "Evaluating")) &  
    td of (sum of number of (statuses of results of it as string) whose (it contains "Locked")) & 
    td of (sum of number of (statuses of results of it as string) whose (it contains "Download Failed")) & 
    td of (sum of number of (statuses of results of it as string) whose (it contains "Offline")) & 
    td of (sum of number of (statuses of results of it as string) whose (it contains "Expired")) &  
    td of (sum of number of (statuses of results of it as string) whose (it contains "<error>")) &  
    td of (sum of number of (statuses of results of it as string) whose (it contains "Failed")) 
) of member actions of bes action whose (name of it = "Some Action Name")

One problem I spot is that the “td” is operating on integer rather than string, so we can cast them to string as below. Note the (it as string) before the sum of number.

(html "<table id=%22resultsTable%22 class=%22sortable%22><th>Patch Name</th><th>Number of reported computers</th><th>Count of installed</th><th>Pending Restart</th><th>Running</th><th>Not Relevant</th><th>Pending Downloads</th><th>Waiting</th><th>Evaluating</th><th>Locked</th><th>Download Failed</th><th>Offline</th><th>Expired</th><th>error</th><th>Failed</th>" & it & html "</table>") 
of concatenations of trs of 
(
    td of ( name of it as string ) & 
    td of ((number of elements of reported computer set of it) as string) & 
    td of (it as string) of (sum of number of (statuses of results of it as string) whose ( it contains "Fixed")) & 
    td of (it as string) of (sum of number of (statuses of results of it as string) whose (it contains "Pending Restart")) & 
    td of (it as string) of (sum of number of (statuses of results of it as string) whose (it contains "Running")) & 
    td of (it as string) of (sum of number of (statuses of results of it as string) whose (it contains "Not Relevant")) &  
    td of (it as string) of (sum of number of (statuses of results of it as string) whose (it contains "Pending Download")) &  
    td of (it as string) of (sum of number of (statuses of results of it as string) whose (it contains "Waiting")) &  
    td of (it as string) of (sum of number of (statuses of results of it as string) whose (it contains "Evaluating")) &  
    td of (it as string) of (sum of number of (statuses of results of it as string) whose (it contains "Locked")) & 
    td of (it as string) of (sum of number of (statuses of results of it as string) whose (it contains "Download Failed")) & 
    td of (it as string) of (sum of number of (statuses of results of it as string) whose (it contains "Offline")) & 
    td of (it as string) of (sum of number of (statuses of results of it as string) whose (it contains "Expired")) &  
    td of (it as string) of (sum of number of (statuses of results of it as string) whose (it contains "<error>")) &  
    td of (it as string) of (sum of number of (statuses of results of it as string) whose (it contains "Failed")) 
) of member actions of bes actions whose (name of it = "Some Action name")

Now your statement looks like this:

var relevance = '(html "<table id=%22resultsTable%22 class=%22sortable%22><th>Patch Name</th><th>Number of reported computers</th><th>Count of installed</th><th>Pending Restart</th><th>Running</th><th>Not Relevant</th><th>Pending Downloads</th><th>Waiting</th><th>Evaluating</th><th>Locked</th><th>Download Failed</th><th>Offline</th><th>Expired</th><th>error</th><th>Failed</th>" & it & html "</table>") of concatenations of trs of (td of (name of it as string) & td of ((number of elements of reported computer set of it) as string) & td of (it as string) of (sum of number of (statuses of results of it as string) whose (it contains "Fixed")) & td of (it as string) of (sum of number of (statuses of results of it as string) whose (it contains "Pending Restart")) & td of (it as string) of (sum of number of (statuses of results of it as string) whose (it contains "Running")) & td of (it as string) of (sum of number of (statuses of results of it as string) whose (it contains "Not Relevant")) & td of (it as string) of (sum of number of (statuses of results of it as string) whose (it contains "Pending Download")) & td of (it as string) of (sum of number of (statuses of results of it as string) whose (it contains "Waiting")) & td of (it as string) of (sum of number of (statuses of results of it as string) whose (it contains "Evaluating")) & td of (it as string) of (sum of number of (statuses of results of it as string) whose (it contains "Locked")) & td of (it as string) of (sum of number of (statuses of results of it as string) whose (it contains "Download Failed")) & td of (it as string) of (sum of number of (statuses of results of it as string) whose (it contains "Offline")) & td of (it as string) of (sum of number of (statuses of results of it as string) whose (it contains "Expired")) & td of (it as string) of (sum of number of (statuses of results of it as string) whose (it contains "<error>")) & td of (it as string) of (sum of number of (statuses of results of it as string) whose (it contains "Failed"))) of member actions of bes actions whose (name of it =="' + actionName.value + '") '; 

I also notice that you use member of actions, which is correct but that is only appropriate for Multiple Action Groups.

2 Likes

@leewei

Thanks Lee Wei! that’s exactly what I needed.

And yes, I use this report for Multiple Actions Group.

Do you have any idea how to modify this relevance:

--Select Action -- <?relevance (html "" & it & html "") of unique values of names of bes actions?>

to sort results by latest id?

Relevance does not provide a sorting feature unfortunately.
“unique values” of strings happens to sort the strings as a by product of its operation.

So if you want to do a Reverse sort on integers (Action IDs are integers), we will have to do it outside of Relevance.

Another issue that we will run into is that we have to be careful to sort the IDs as integer so that when reverse sorted, 10 does come before 9.

<select id="actions" name="actions" size="1" >
     <option value="default" selected="true" style="background-color: #532900; color: white;">--Select Action --</option>
</select>

Here is the sample code, assuming that before this block in the custom report, you have a Select HTML element like the above with the ID “actions”.

<script type="text/javascript">
    <?relevance javascript array "options" of ("<option label=%22" & last 4 of ("000" & id of it as string) & "%22 value=%22" & name of it & "%22>" & id of it as string & " - " & name of it & "</option>") of bes actions ?>
    
    options.reverse();
    
    var dropList = document.getElementById("actions");
    
    for ( var i = 0; i < options.length; i++)
    {
        var child = document.createElement("option");
        child.innerHTML = options[i];
        dropList.appendChild(child);
    }
</script>

There are 2 unusual techniques in the Relevance statement.
Firstly, I use the Last 4 of “000” to pad the integers so that they are always 4 digits for easy sorting.

The number always look something like this:
1000
0987
0087

Secondly, javascript array is a not so common Relevance statement that I use to automatically generate the Relevance output as a JavaScript string array. That is why this following statement is a simple option.reverse() which is a standard JavaScript array method.

1 Like

@leewei

Thanks again! It worked. Your knowledge of the topic is incredible! Also thanks for the explanation of your code.

Hello
I have another problem with table and custom reports:

var relevance = '(html "<table id=%22resultsTable%22 class=%22sortable%22><th>Offer ID</th><th>Offer Name</th><th>ID of SubOffer</th><th>Name of the SubOffer</th><th>Size of SubOffer</th>" & it & html "</table>") 
of concatenations of trs of 
(
td of (id of it as string) & 
td of (name of it as string) & 
td of ((id of source fixlet of it as string| "no id") & 
td of (name of it as string| "no name") & 
td of (((download size of source fixlet of it / (1024*1024)) as string & " MB")| "no size information")
) of components of component groups of source fixlets of it) of bes actions whose (exists member actions of it) ';

Could you please tell me what is wrong there? Can you tell me how to troubleshoot Web Reports? Thanks in advance!

What is the symptom of your problem/error?

@leewei

No results on the screen. I can see results when I use exactly the same relevance outside the table.

I modified my relevance and table as below:
(please ignore headers, as these below contain name of columns for each value that I want to read)

Offer ID Offer Name ID of SubOffer Name of SubOffer Size of SubOffer (MB)
  	<?relevance trs of (td of (id of it as string) & (td of (name of it) & td of (it as string) of ((download size of source fixlet of it/ (1024*1024)) as string) ) of components of component groups of source fixlets of it) of bes action whose (id of it = 67582) ?>

but I am getting “A singular expression is required.” error.

When I remove id of action from the relevance above then it works fine:

<?relevance trs of ((td of (name of it) & td of (it as string) of ((download size of source fixlet of it/ (1024*1024)) as string) ) of components of component groups of source fixlets of it) of bes action whose (id of it = 67582) ?>

so there seems to be a problem with combining id or name of action with data from fixlets when I try to put them in the table.

The below relevance works properly in web reports(containing all data that I need)

<?relevance (id of it, name of it,((id of source fixlet of it as string| "no id"),(name of it| "no name") , (((download size of source fixlet of it / (1024*1024)) as string & " MB")| "no size information")) of components of component groups of source fixlets of it) of bes actions whose (id of it = 67582)?>

I think there might be 2 different problems here.
When you assign the Relevance statement to a variable, it does not do anything.
Are you using the EvaluateRelevance() function to run the Relevance and then do something with the results?

You also mentioned at the end that the below Relevance works properly and containing everything you need.
What are you doing with the Relevance subsequently?

I notice that you are trying to total the download sizes for all the Fixlets in a Baseline?
Then we need a Sum statement somewhere for download sizes, so I am not sure if the Relevance you have is working correctly.

Maybe this is a statement that you can use as an example:

trs of
(
    td of (id of it as string) &
    td of name of it &
    td of (it as string & "MB") of 
        relative significance place 2 of 
        (it as floating point/(1024*1024)) of 
        sum of download sizes of source fixlets of 
        components of component groups of 
        source fixlets of it
) 
of bes action whose (id of it = 67582)


@leewei

Thanks for that suggestion. It works.

I have another question, this time regarding links in table. I have the following code:

function test(ID_PARAMETER) {

          
    document.getElementById('resultsDiv').innerHTML = EvaluateRelevance('(id of it , name of it ,((id of source fixlet of it as string| "no id"),(name of it| "no name")  , (((download size of source fixlet of it / (1024*1024)) as string & " MB")| "no size information")) of components of component groups of source fixlets of it) of bes actions whose (id of it = ID_PARAMETER)');
}

function search(){
    var divRes = document.getElementById('resultsDiv');
    
    divRes.innerHTML = 'Searching...';
    divRes.style.display = 'block';
                   
    var relevance = '(html "<table id=%22resultsTable%22 class=%22sortable%22><th>Patch Name</th><th>Number of reported computers</th><th>Count of installed</th> & it & html "</table>") of concatenations of trs of (td of (html tag ("span", attr lists of ("onclick", "test()" ; "class" , "pseudo_link"), name of it as string)) & td of ((number of elements of reported computer set of it) as string) & td of (it as string) of (sum of number of (statuses of results of it as string) whose (it contains "Fixed")) ) of member actions of bes actions whose (name of it ="' + actionName.value + '") ';

Could please tell me if it is possible to pass name of it as string to the function test()

("onclick", "test()" ; "class" , "pseudo_link"), name of it as string))

BTW thanks again for your patience and useful advices!

@pldany, maybe we should start a new thread so that the topics can be better separated?

@pldany, the code fragments are getting involved for me to understand the picture.
You are welcome to message me directly and I am happy to help you directly offline.