This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Apr 23, 2012, 8:58 AM
18 Posts

View Control Filter by Column Value (Keys)

  • Category: Other
  • Platform: Windows
  • Release: 8.5.2
  • Role: Developer
  • Tags:
  • Replies: 6
Hi
 
I am trying to filter a view control using a column value using a value held elsewhere.  It is multiple keys but will not display the view entries.  I have entered the expected result of my code as the keys and it works.  When left to the code it does not work.  Here is the code which I know returns the correct keys.  I have looked through different forums and checked all the usual thing ( like the columns are sorted), But still it does not work.
 
Anyone have any ideas where I should look next?
 
Many thanks in advance
 
Matt
 
 var database = session.getDatabase(@DbName()[0], @DbName()[1]);
var profDoc:NotesDocument = database.getProfileDocument("DbProfile","");
var db = profDoc.getItemValue("CustomiserRepId");
var vw = "Custom";
var key = "XpageSouthRegions" ;

var lookup = @DbLookup( db, vw, key, 2,"[FailSilent]");
var array = new Array();
var tmpstr = lookup.valueOf();   
array = tmpstr.split("," );
var qstring;

for( var i = 0; i < array.length; i++ ){
    if (i == 0){
        qstring = "'"+array[i]+"'";
    }else{
        qstring = qstring+",'"+array[i]+"'";
    }
}    

return qstring.toString()
Apr 23, 2012, 10:45 AM
126 Posts
Re: View Control Filter by Column Value (Keys)
Given that you say it works when you hard code the keys, it would be obvious to assume that the output of your code is not in the same format / type of variable (string vs array etc.) that the property is expecting. I would print out the result of your code and compare it to the hardcoded keys and see is what ur passing into the property exactly the same as the hardcoded keys. 
Apr 23, 2012, 10:54 AM
18 Posts
Re: View Control Filter by Column Value (Keys)
Thanks for your reply Simon.
 
I have checked by having a computed field on the page that uses the same code as previously posted and this returns the correct format of keys. I copied this output to test the hard codes keys. Hence my confusion when the same code does not produce the same results as the had coded keys.  I have tried to look to the computed field  for the keys but that doesn't seem to work either, although not 100% sure I have got the right 'getValue' code.
 
Cheers
 
Matt
Apr 23, 2012, 12:31 PM
126 Posts
Re: View Control Filter by Column Value (Keys)
hhhmm, sounds a little strange all right. 
 
to get the value of a computed filed it is just  
 
var keys = getComponent("<controlId>").value;
 
To test script like this to see is it working you can print to the server console by using  " print(<value>) " in server side script or " console.log(<value>) " in client side. Makes it much easier to deal with then making guesses and adding controls for display purposes. Nothing jumps out of your code as wrong, but I no computed fields can apply converters and escaping etc. the fact that whats appearing in the field works when hard coded again leaves me to believe that the var type or the format of the string being sent in is not correct.
 
leave the computed field on the page and do a " print("QString: " + qstring) " and see do they match. Also with javascript using the "  print("Type: " + typeof qstring) " command can be handy to make sure you are supplying the correct variable type to a property etc.
 
Simon 
Apr 24, 2012, 7:45 AM
18 Posts
Re: View Control Filter by Column Value (Keys)
As per the help relating to Keys, I have altered my code to create a vector of keys (checked this using your tips, Simon) but the entries are not being shown even though I am using a vector, is there a gotcha here that I don't know about?
 
Matt
Apr 24, 2012, 9:07 AM
126 Posts
Re: View Control Filter by Column Value (Keys)
I'm not aware of any.
 
 
he's using a method  .setKeys(), I would imagine it would take either a string, an array or a string separated by commas e.g. "val1, val2, val3"
 
I'm not sure what your problem is, I've had similar issues before but they all came down to malformed strings. 
 
Simon 
Apr 24, 2012, 12:31 PM
18 Posts
Re: View Control Filter by Column Value (Keys)
Thanks  for your help , but I'm giving up on trying to get the view to filter on multiple keys in xpages, I'll filter it  on th enotes view
 
Matt

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal