3

Im trying to get all the past event log based on filter criteria using filter.get() and then transform data to show in a table. However, I'm not able to figure out how to retrieve the data from the resulted data. In the below, if I log the result var inside the get function call, I'm able to see the data. However, I'm not able to make meaning out of dataset3. Any inputs will be helpful here as I'm a newbie to both Javascript and ethereum.

var filter = AutoClaims.approveClaimEvent({ClaimStatus:web3.sha3("VERIFIED",  {encoding:"hex"})}, { fromBlock: 0, toBlock: 'latest' });
var dataset3 = filter.get(function(error,result){
              if (!error)
                {
                    $("#loader").hide();
                    console.log(timestamp);
                    console.log("Result Length:"+ result.length);
                    if(result.length>0){
                     for (var i = 0; i < result.length; i++) {
                      if(web3.sha3(AutoClaims.claimResult(result[i].args._policyNo.toNumber())[0],{encoding:"hex"}) == web3.sha3("VERIFIED",  {encoding:"hex"}))
                      {
                          dataset2= "["+AutoClaims.claims(i+1)[1]+","+result[i].args._policyNo.toNumber()+","+AutoClaims.claims(i+1)[3]+","+AutoClaims.claims(i+1)[6]+","+ AutoClaims.claims(i+1)[5]+","+ AutoClaims.claims(i+1)[7]+"],";
                      }
                    }
                  }
                }
              else {
                    $("#loader").hide();
                    console.log(error);
                   }
});
filter.stopWatching();
console.log(dataset2);
console.log(dataset3);
0

Not sure if I am 100% right. But since its an asynch callback, there is no way to return the data from this function. So I got it working by changing the approach. Instead of returning data, I have used display JQuery table within the function itself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.