E9.2 JRuby script to return business view data in HTML table format

kaliraj

Member
Hi,

Am able to retrieve data from data request (table) and pass it to JRuby script to display the data in HTML table format. But the same is not working when trying to retrieve from business view.

Below is the working JRuby script involving table. Any suggestions on how to make it work for business view ?

require 'json'
def main(orchAttr, inputMap)
returnMap = {}
# Add logic here
input = inputMap["input"]
jsonIn = JSON.parse(input)

#Header row for HTML table
rowsText = "<table><tr><th style='text-align: left'>Number</th><th style='text-align: left'>Name</th><th style='text-align: left'>Business Unit</th><th style='text-align: left'>Search Type</th></tr>"

#Get the table array
array = jsonIn["fs_DATABROWSE_F0101"]["data"]["gridData"]["rowset"]

#Create an HTML table row for each record in the array
array.each { |row|

abno=row["F0101_AN8"].to_s
name=row["F0101_ALPH"].to_s
hmcu=row["F0101_MCU"].to_s.strip! + "-" + row["F0101_MCU_desc"].to_s
at1=row["F0101_AT1"].to_s + "-" + row["F0101_AT1_desc"].to_s

rowsText = rowsText + "<tr><td>" + abno + "</td><td>" + name +"</td><td>" + hmcu + "</td><td>" + at1 + "</td></tr>"
}

#close the HTML table
rowsText = rowsText + "</table>"
#rowsText = rowsText + "<script>alert('test')</script>"

returnMap["HTMLTableOfData"] = rowsText

return returnMap
end
 
Back
Top