Custom report - relevance help

I have the following (working relevance) that produces a patch report measured against a baseline.

<?relevance
 (html "<table id=resultsTable class=sortable> <colgroup><col style=width:140px;/><col style=width:480px;/><col/><col/><col style=width:120px;/><col/></colgroup>" & html ("<th>Computer Name</th><th>Group</th><th>Applicable Patch</th>
<th>Severity</th><th>Category</th><th>Release Date</th><th>CVE</th>") & (it) & html "</table>" ) of concatenations of trs of (td of (item 0 of item 0 of it as string) & td of (item 1 of item 0 of it as string) & td of (item 1 of it as string) & 
td of (item 2 of it as string) & td of (item 3 of it as string) & td of ((year of it as string & "/" & (month of it as two digits) as string & "/" & (day_of_month of it as two digits) as string)) of (item 4 of it as date) & td of (item 5 of it as string))
 of(

(if (size of item 1 of it > 0) then ((name of it, concatenation ";" of names of bes computer groups of it) of elements of item 1 of it) else ("<none>", "<none>")),
(if (exists Name of item 0 of it| false) then (concatenations "%0A" of (Name of item 0 of it as string)) else ("<none>")), 
(if (exists Source Severity of item 0 of it| false) then (concatenations "%0A" of (Source Severity of item 0 of it as string)) else ("<none>")), 
(if (exists Category of item 0 of it| false) then (concatenations "%0A" of (Category of item 0 of it as string)) else ("<none>")), 
(if (exists Source Release Date of item 0 of it) then (Source Release Date of item 0 of it as string) else ("Fri, 15 Feb 1980")), 
(if (exists CVE ID List of item 0 of it | false) then (concatenations "%0A" of (CVE ID List of item 0 of it as string)) else ("<none>"))) 

of (item 0 of it , intersection of (applicable computer set of item 0 of it; item 1 of it)) whose (size of item 1 of it > 0) of (elements of item 0 of it , item 1 of it) 
of (set of fixlets whose (globally visible flag of it = true) 
of results of source fixlets of components of component groups of bes fixlets whose (baseline flag of it and name of it contains "Catchup Win - Apr"),
union of (member sets of bes computer groups whose (name of it as lowercase = "non-prod")))
?>

I would like to add an additional column. A custom property (ie. mysetting). This is what i’ve attempted - it’s not working :frowning:


<?relevance
 (html "<table id=resultsTable class=sortable> <colgroup><col style=width:140px;/><col style=width:480px;/><col/><col/><col style=width:120px;/><col/></colgroup>" & html ("<th>Computer Name</th><th>Group</th><th>Applicable Patch</th>
<th>Severity</th><th>Category</th><th>Release Date</th><th>CVE</th>") & (it) & html "</table>" ) of concatenations of trs of (td of (item 0 of item 0 of it as string) & td of (item 1 of item 0 of it as string) & td of (item 1 of it as string) & 
td of (item 2 of it as string) & td of (item 3 of it as string) & td of ((year of it as string & "/" & (month of it as two digits) as string & "/" & (day_of_month of it as two digits) as string)) of (item 4 of it as date) & td of (item 5 of it as string) & td of (item 6 of it as string))
 of(

(if (size of item 1 of it > 0) then ((name of it, concatenation ";" of names of bes computer groups of it) of elements of item 1 of it) else ("<none>", "<none>")),
(values of results from (bes property "mysetting") of item 0 of it),
(if (exists Name of item 0 of it| false) then (concatenations "%0A" of (Name of item 0 of it as string)) else ("<none>")), 
(if (exists Source Severity of item 0 of it| false) then (concatenations "%0A" of (Source Severity of item 0 of it as string)) else ("<none>")), 
(if (exists Category of item 0 of it| false) then (concatenations "%0A" of (Category of item 0 of it as string)) else ("<none>")), 
(if (exists Source Release Date of item 0 of it) then (Source Release Date of item 0 of it as string) else ("Fri, 15 Feb 1980")), 
(if (exists CVE ID List of item 0 of it | false) then (concatenations "%0A" of (CVE ID List of item 0 of it as string)) else ("<none>"))) 

of (item 0 of it , intersection of (applicable computer set of item 0 of it; item 1 of it)) whose (size of item 1 of it > 0) of (elements of item 0 of it , item 1 of it) 
of (set of fixlets whose (globally visible flag of it = true) 
of results of source fixlets of components of component groups of bes fixlets whose (baseline flag of it and name of it contains "Catchup Win - Apr"),
union of (member sets of bes computer groups whose (name of it as lowercase = "non-prod")))
?>

Try below, I have added OS property results, you can replace it with yours.

<?relevance
(html "<table id=resultsTable class=sortable> <colgroup><col style=width:140px;/><col style=width:480px;/><col/><col/><col style=width:120px;/><col/></colgroup>" & html ("<th>Computer Name</th><th>Group</th><th>OS Name</th><th>Applicable Patch</th>
<th>Severity</th><th>Category</th><th>Release Date</th><th>CVE</th>") & (it) & html "</table>" ) of concatenations of trs of (td of (item 0 of item 0 of it as string) & td of (item 1 of item 0 of it as string) & td of (item 2 of item 0 of it as string) & td of (item 1 of it as string) & 
td of (item 2 of it as string) & td of (item 3 of it as string) & td of ((year of it as string & "/" & (month of it as two digits) as string & "/" & (day_of_month of it as two digits) as string)) of (item 4 of it as date) & td of (item 5 of it as string))
 of(

(if (size of item 1 of it > 0) then ((name of it, concatenation ";" of names of bes computer groups of it as string, value of results from (bes property "OS") of it) of elements of item 1 of it) else ("<none>", "<none>", "<none>")),
(if (exists Name of item 0 of it| false) then (concatenations "%0A" of (Name of item 0 of it as string)) else ("<none>")), 
(if (exists Source Severity of item 0 of it| false) then (concatenations "%0A" of (Source Severity of item 0 of it as string)) else ("<none>")), 
(if (exists Category of item 0 of it| false) then (concatenations "%0A" of (Category of item 0 of it as string)) else ("<none>")), 
(if (exists Source Release Date of item 0 of it) then (Source Release Date of item 0 of it as string) else ("Fri, 15 Feb 1980")), 
(if (exists CVE ID List of item 0 of it | false) then (concatenations "%0A" of (CVE ID List of item 0 of it as string)) else ("<none>"))) 

of (item 0 of it , intersection of (applicable computer set of item 0 of it; item 1 of it)) whose (size of item 1 of it > 0) of (elements of item 0 of it , item 1 of it) 
of (set of fixlets whose (globally visible flag of it = true) 
of results of source fixlets of components of component groups of bes fixlets whose (baseline flag of it and name of it contains "March2024"),
union of (member sets of bes computer groups whose (name of it as lowercase = "automaticgroup")))
?>

My Test results:

1 Like

Thanks for your help @vk.khurava - works great

1 Like

Follow up question… what if you have not yet tagged a computer with that custom setting (“OS” in this example). Then you will get error: “Singular expression refers to nonexistent object.” When running the report. There needs to be a check to see whether the client setting exists. I’m trying to modify this section of the relevance but have not yet been successful.

(name of it, concatenation “;” of names of bes computer groups of it as string, value of results from (bes property “OS”) of it) of elements of item 1 of it) else (“”, “”, “”))

Rather than making changes to your custom report, you should recode any RP for which you are seeing these results to ensure proper error handling.

Although error handling in custom reports is also possible, fixing the source is always advised.

“Singular expression refers to nonexistent object” can be avoided by using the following:

value of results from (bes property "OS") of it | "Empty Cell"

1 Like

i was making it more complicated than necessary… was trying to use “if exists then else” logic. Thank you again for you help!