0
votes

how to pass parameter from a dataset row value to java function accessed via scripted datasource?

I have a java class that deccrypts an encrypted string

class Decryptor{
public String decrypt(text)
{
.
.
StandardPBEStringEncryptor textEncryptor = new StandardPBEStringEncryptor();
return textEncryptor.decrypt(text);
}
}

I imported it to my birt report that goes like this: I created a dataset named dsCode with column "code";

open:
sessionUtil = new  Packages.com.reports.server.generator.data.SessionUtil();
sessionUtil.openCurrentSession();
c = new Decryptor();
textDecrpt = c.decrypt("O6pas1t9NyY9bmAtjvX2NA==");

fetch;
row["code"] = textDecrpt ;
return true;

this is working fine. however I want to pass a value to the decrypt function from anther dataset row value(encryptedCodecolumn of dsCustomerIfdo). How do I do this? I made the dsCode as datasource of a subreport and I added parameter called pmCode to the dsCode and passed a value to it using "Data Set Parameter Binding" and made the script like this

textDecrpt = c.decrypt(params["pmCode"]);

this gives me an error end of file undefined. How do i access a dataset row value in javascript? or pass a rowvalue of a dataset to a script function?

this is not working

  var dset = reportContext.getDesignHandle().findDataSet("dsCustomerInfo");
   textDecrpt = c.decrypt(dset.getRow("encryptedCode").value);

thanks

1

1 Answers

0
votes

I solved it by not using another dataset like what I intially tried. Just used the dsCusotmerInfo, added a computed column called decryptedCode and added the scirpt on fetch on it. This decrypts all code of all customers.

sessionUtil = new  Packages.com.reports.server.generator.data.SessionUtil();
sessionUtil.openCurrentSession();
c = new Decryptor();
row["decryptedCode"] = c.decrypt(row["encryptedCode"]);
return true;