Ok this seems so silly but I'm having some trouble getting this to work. I want to do an #DbColumn() or #DbLookup() to another database. Same server - BUT it's in a folder. And I can't get a result. The view of the database in question is sorted by the first column.
I'm trying to populate choices of a combobox.
I've tried that built in #DbColumn():
var dbname = new Array("", "myfolder\\myDB.nsf");
return #DbColumn(dbname, "byCode", 0)
I've tried that with and without the "double slashes" and with column 0 and also column 1.
I've also tried the XSnippet :
http://openntf.org/XSnippets.nsf/snippet.xsp?id=dblookup-dbcolumn-with-cache-sort-and-unique
That would be my preferred method really because of caching. I tried creating a SSJS function:
function getFacilityList() {
var dbPath = database.getFilePath().split(database.getFileName())[0];
return DbColumnArray("","myfolder\\myDB.nsf","cache", "sort", "byCode", 0)
}
Which I think should have worked but did not.
Any thoughts would be appreciated! Thanks
Try:
var dbname = session.getServerName() + "!!" + "myfolder\\myDB.nsf";
return #DbColumn(dbname, "byCode", 0)
Related
var ref = db.ref("main")
var usersRef = ref.child("users");
var accountIdVal = 56473;
What datatype is the equalTo query commmand using when I try to search with a variable, like below it does not return the desired result.
usersRef.orderByChild("accountID").equalTo(accountIdVal).once("value",function(snapshot){
//returns all the values in users
});
when the same thing is tried with non referenced value like below it works fine
usersRef.orderByChild("accountID").equalTo(56473).once("value",function(snapshot){
//returns the exact user
});
even when I use accountIdVal.toString() it does not seem to work, am I missing something here?
Hi thanks for the help I figured out the answer it was because I was getting the value of the variable as a Long, it was checking for a Integer and not a string so the datatypes were not matching up.
I have a multivalue field called freeDaysPool which has multiple dates as strings. With the following code, the search does not return anything. If I leave that field out, the search works just fine with the two other fields. I read that I should use CONTAINS with multivalue fields but then I got query not understandable.
I've tried the back-end field as a date field and as a text field and tested all kinds of query combinations and date formats but no luck. Any help is really appreciated.
This is the search button code:
var query = new Array("");
var cTerms = 0;
// Field 1
var search01 = getComponent("searchcustomReservationField01").getValue();
if (#Contains(#Text(search01),"any city")){"";}
else {query[cTerms++] = '[customReservationField01]="' + search01 +'"'};
// Field 2
var search02 = getComponent("searchcustomReservationField02").getValue();
if (#Contains(#Text(search02),"any city")){"";}
else {query[cTerms++] = '[customReservationField02]="' + search02 + '"'};
// Date 1
var formatter = new java.text.SimpleDateFormat("d.M.yyyy");
query[cTerms++] = 'FIELD freeDaysPool = ' + formatter.format(getComponent("searchcustomDateField01").getValue());
// if query is still empty, we fill it with asterisk
if(query == "" || query == null){
query[cTerms++] = "*";
}
// make all as string
qstring = query.join(" AND ").trim();
sessionScope.searchString = qstring;
It will return query as:
[customReservationField01]="Oslo" AND [customReservationField02]="Oslo" AND FIELD freeDaysPool = 6.2.2015
AFAIK date values in formulas (and a query is a formula) have to be noted like
[06.02.2015]
to compare them. Just try to use your formular in the Notes Client to do a fulltext search. If you get results and no errors you found the correct format. That's at least the way I test queries as I'm not able to remind the syntax for years :-D
Thank you for all the help! Seems that Domino keeps the field type as date field even if you change it back to text field (noticed that from the notes FTsearch). I created completely new text field and added the days as strings in dd.MM.yyyy format. I also search them as strings and it works fine.
The changed code bit now looks like this:
// Date 1
var formatter = new java.text.SimpleDateFormat("dd.MM.yyyy");
query[cTerms++] = '[freeDays] CONTAINS "' + formatter.format(getComponent("searchcustomDateField01").getValue())+'"';
I have a 2 column sorted view and try to get a document the following code:
var searchArr = new java.util.Vector();
searchArr.addElement(10000310);
searchArr.addElement(45);
var customerdoc:NotesDocument = viw.getDocumentByKey(searchArr,true);
but the result is null.
If I use only the first element for the key (10000310), then I get (the first) doc with that key. But with the 2-element-vector the lookup returns null.
the same in LotusScript works fine:
Dim searchkey(1) As Double
searchkey(0) = 10000307
searchkey(1) = 45
Set doc = luview.Getdocumentbykey(searchkey, true)
gives me the document I need.
Confusing, for me ....
Uwe
This is a known bug, hopefully to be fixed in 9.0.2. See this question getDocumentByKey with view category separated by "\\" in XPages
Your LS example uses an array, not a Vector. I am not even sure if it is intended to work with a Vector - never did that. So just use an array here, too, as the key.
I am trying to perform an #DbLookup to another server/database and continually receive an "undefined" return message. The database exists, the view name is correct, the key is correct, as well as the column I am trying to return. I have reader access to the database.
I have tried all these combinations for the server/file path, but none seem to work:
var dbName = new Array(session.getServerName(), "my/folder/thisdb.nsf");
var dbName = session.getServerName() + "!!" + my\\folder\\thisdb.nsf;
var dbName = "CN=Server/OU=Name/O=This" + "!!" + my\\folder\\thisdb.nsf;
var dbName = [#DbName([0]), "my/folder/thisdb.nsf"];
I have found this post and tried most of the combinations:
http://www.c-lutions.com/c-lutions/mcblog.nsf/dx/08242012095124AMJMMJ69.htm
Are there any other combinations I can try?
Thanks!
Is your folder's name my folder with a space in it? This could be the challenge. I would suggest to ease your pain....
Create one XPage in your target database, have one computed field on it with #DbName() as formula and see what is coming back. Besides that, your formulas have some issues (comments below the entries):
var dbName = new Array(session.getServerName(), "my/folder/thisdb.nsf");
looks OK unless your folder isn't a subfolder of my. Folders need to be relative to the data directory.
var dbName = session.getServerName() + "!!" + my\\folder\\thisdb.nsf;
dbName must be an array, this one isn't. Also there are no quotes around the file name
var dbName = "CN=Server/OU=Name/O=This" + "!!" + my\\folder\\thisdb.nsf;
same here: must be an array, quote is missing. It is confusing since the data source syntax uses the (CN) format of this: #Name("[CN]";#Subset(#DbName();1)+"!!....
var dbName = [#DbName([0]), "my/folder/thisdb.nsf"];
almost there. #DbName() doesn't take a parameter, so you would write:var dbName = [#DbName()[0], "my/folder/thisdb.nsf"]; or use var dbName = [#Subset(#DbName(),1), "my/folder/thisdb.nsf"];
You also can check great samples to play with.
Make sure the second server is in a trusted server group that is trusted by the first server. For security reasons XPages (and LotusScript) running on any server is unable to access the contents of databases if they are not in the same trusted server group.
I am using Fluent NHibernate for my ORM. In doing so I am trying to use the NHibernate LINQ syntax to fetch a set of data with the power of LINQ. The code I have works and executes correctly with the exception being that a timeout is thrown if it takes longer than roughly 30 seconds to run. The question I have is how do I extend the default 30 second timeout for LINQ statements via NHibernate?
I have already seen the posts here, here, and here but the first two refer to setting the DataContext's Timeout property, which does not apply here, and the third refers to setting the timeout in XML, which also does not apply because I am using Fluent NHibernate to generate the XML on the fly. Not only that but the post is 2 years old and Fluent NHibernate has changed since.
With the ICriteria objects and even HQL I can specify the timeout, however that is not the goal here. I would like to know how to set that same timeout and use LINQ.
Example code:
using (var session = SessionFactory.OpenSession())
using (var transaction = session.BeginTransaction())
{
var query = (from mem in session.Query<Member>()
select mem);
query = query.Where({where statement});
int start = (currentPage - 1) * max);
if (start > 0)
query = query.Skip(start).Take(max);
else
query = query.Take(max);
var list = query.ToList();
transaction.Commit();
return list;
}
This code (where statement does not matter) works for all purposes except where a timeout occurs.
Any help is appreciated. Thanks in advance!
I ended up setting the command timeout for the Configuration for Fluent NHibernate. The downside to this is that it sets the timeout for ALL of my data access calls and not just the one.
Example code:
.ExposeConfiguration(c => c.SetProperty("command_timeout", (TimeSpan.FromMinutes(10).TotalSeconds).ToString()))
I found this suggestion from this website.
Nhibernate has extended the IQueryable and added a few methods https://github.com/nhibernate/nhibernate-core/blob/master/src/NHibernate/Linq/LinqExtensionMethods.cs
var query = (from c in Session.Query<Puppy>()).Timeout(12);
or
var query = (from c in Session.Query<Puppy>());
query.Timeout(456);
I've just spent fair amount of time fighting with this and hopefully this will save someone else some time.
You should use the .Timeout(120) method call at the very last moment to make sure it is used. TBH I'm not 100% sure on why this is but here are some examples:
WILL WORK
query = query.Where(x => x.Id = 123);
var result = query.Timeout(120).ToList();
DOESN'T WORK
query.Timeout(120);
query = query.Where(x => x.Id = 123);
var result = query.ToList();
If done like the second (DOESN'T WORK) example, it seems to fall back to the default System.Transaction.TransactionManager.DefaultTimeout.
Just in case anyone is still looking for this and finds this old thread too...
Query.Timeout is deprecated.
You should use WithOptions instead:
.WithOptions(o => o.SetTimeout(databaseTimeoutInSeconds))