Javascript / use session relevance with variables

Hi Guys,

I want to use a variable defined in javascript to struct my session relevance string.
is it possible to achive it without bigfixme libraries ?

for example;

var myapp = “7zip”;
var relevancestring = ‘number of names of computers of (results of bes properties “Installed Applications - Windows”) whose (exists values whose (it as string as lowercase starts with "’ + myapp + ‘" as lowercase) of it )’;
var result = <?relevance relevancestring ?>;

1 Like

Hello,
I’m not sure if you’re asking about just evaluating relevance in Javascript or creating dynamic dashboard content where static <?relevance ... ?> is not enough.

In both console dashboards and webreports you can use EvaluateRelevance function. It’s part of built-in DashboardAPI and you don’t have to include any libraries. The last command in your example would be

var result = EvaluateRelevance(relevancestring);

If you were asking about dashboard dynamic content, check the following simple dashboard example

<?xml version="1.0"?>
    <BES>
      <Wizard>
      <Title>Computers with app</Title>
      <UIHooks LaunchType="Document" RequiresAuthoring="false"></UIHooks>
       <DefaultPage>pg01</DefaultPage>
       <Page Name="pg01" DocType="HTML5" > 
       <Title>Computers with app</Title>
    	<HTML>
    	<![CDATA[
    	<div>
    		<select id="appname">
    			<option value="7zip">7-Zip</option>
    			<option value="AnotherApp">Another App</option>
    		</select><br /><br />
    		<button type="button" onClick="runscan();">Scan</button>
    	</div><br /><br />
    	<div id="result"></div>
    	<script>
    	function runscan() {
    		var listbox = document.getElementById("appname");
    		var myapp = listbox.value;
    		var myappname = listbox.options[listbox.selectedIndex].text;
    		var relevancestring = 'number of computers of (results of bes properties "Installed Applications - Windows") whose (exists values whose (it as string as lowercase starts with "' + myapp + '" as lowercase) of it )';
    		var result = EvaluateRelevance(relevancestring);
    		document.getElementById("result").innerHTML = "The application "+myappname+" is installed on "+result+" endpoints";
    	}
    	</script>
    	]]>
    	   </HTML>
    	 </Page>
       </Wizard>
    </BES>
1 Like