0
votes

In the onclick event of a button , I would like to search for a notes document , with multiple conditions with ssjs.

I have a form with a few fields. Now I would like to find a notes document where field a="123" and field b="456" field c="789" and field d >"A123456" , and then I would like to read the contents of field e.

If it was the search in a view I would use something like :

var tmpArray = new Array("");
var cTerms = 0;
if(viewScope.fong != null & viewScope.fong != "") {
tmpArray[cTerms++] = "(FIELD Site = \"" + viewScope.fong + "\")"
}
if(@Text(viewScope.sDate) != null & @Text(viewScope.sDate) != "") {
tmpArray[cTerms++] = "(FIELD StartDate = \"" + @Text(viewScope.sDate) + "\")"
}
qstring = tmpArray.join(" AND ").trim();
viewScope.queryString = qstring;
return qstring 

If I only had 1 condition I would have used @DbLookup (and still how select documents >"A123456"?)

What's the best way of dooing this in ssjs ?

UPDATE

tried with FTSearch , but it seems in the searchkey "FIELD d > A123456" , doesn't seem to work

OTHER UPDATE

var dc = db.FTSearch("FIELD a=123 and FIELD b =456 and FIELD d =A123456"); seems to work but

var dc = db.FTSearch("FIELD a=123 and FIELD b =456 and FIELD d >A123456"); doesn't. It gives error : Exception occurred calling method NotesDatabase.FTSearch(string) null

1
If you indeed wrote "FIELD d > A123456" then the test would only succeed if you had a variable named A123456 and it contained a value greater than (whatever that means in this context) d. You probably wanted d > "A123456"Duston
This doesn't work. Then I get an error message : "Exception occurred calling method NotesDatabase.FTSearch(string) null" when I change the > with = and remove the "" it works , but doesn't give the correct result of courseMarc Jonkers
d > "A123" does not work, as A123 is a string, which cannot be compared with greater or less. If you are already on 10.0.1 you may have a look at DQLumeli

1 Answers

0
votes

If you want to use comparison operators > and <, then you need to use the NotesDatabase.Search method instead of FTSearch. Search is slower and can't access data in non-summary (i.e., rich text) fields, but it has all the same capabilities that you can use in a view selection formula.