Display logic based on field's value length - openbravo

Is it posible to create a display logic condition with the size or length of a field's value?
For example: #upc.length#<13 or anything like that?
I have tried it that way but it is not working. I would appreciate if anyone knows the logical operators for this. In the openbravo howtos is not very explanative.
Thanks.

As suggested in the comment, use an auxiliary input.
Auxiliary Input
Name : upcLength
SQL
select (case when length (upc) > 13 then 'Y' else 'N' end) as length
from table where table_id = #table_id#
In Windows, Tabs and Fields, for a field add the display logic.
#upcLength#='Y'
PS: Assumed DB Postgres.

Related

Can someone help me with Exception occurred calling method NotesDatabase.FTSearch(string)

I'm trying to do a database full text search and struggling to get it to work.
Since I'm working with date fields, I deleted my full text index, set all my blank date fields to a fictitious date (3/15/2050), compacted the db and then rebuilt the full text index.
However, I am still getting the error for this query string:
(FIELD Form CONTAINS 'Opp') AND (FIELD Topic CONTAINS 'A') AND (FIELD DateTeam >= 3/1/2019) AND (FIELD DateTeam <= 3/31/2019)
I didn't have the single quotes in there initially, but tried it as a suggestion from another post. I also tried putting # before and after my dates, but no luck there either.
What am I missing? My customer is getting frustrated.
You didn't post the verbiage in the exception, nor say what Domino version you were using, so this is somewhat guesswork.
It could be that the UNK table (Domino's internal field catalog) thinks the field is a string field. The first value stored in a field is the type that the FT index uses to determine the indexed data type. Of course any type can be stored in the NSF data but the FT code tries to limit this type of search to fields it believes will work.
Now if those CONTAINS values are actually = values, then DQL can help you. We'll be putting CONTAINS as a verb into DQL in V11, but it (DQL) can certainly perform your date range term. Just a thought.
-John Curtis
This might help: https://www-10.lotus.com/ldd/dominowiki.nsf/dx/full-text-syntax
As far as I know date values must be in [] to work.
A good start is to test your formula in the client with the FT search function instead of altering your code.
By the way: you can shorten your formula omitting the FIELD keyword and putting the field name also in [].
I tried this in my mail database:
(FIELD Form CONTAINS "Memo") AND (FIELD Subject CONTAINS "the") AND (FIELD PostedDate >= 3/1/2019) AND (FIELD PostedDate <= 30/6/2019)
And it works correctly. So double quotes instead of single, and you might have to check whether your date format corresponds with the server's.
The approach I was taking was correct. The problem, however, was that my update agent to set all the date fields had a typo in it so it wasn't setting the right fieldnames to dates. My oversight. Once I found that and corrected it, I retraced my steps and it all works as intended now. Thank you to all for helping me find the solution.
For anyone else, I took these steps:
Open database properties and delete the full text index
Run this command on the console to compact the db: lo compact folder/db.nsf -c
Run an agent against all the docs to set the date fields to a fictitious date
Open database properties again and create a new full text index
When completed, run this command on the console: load updall -f folder/db.nsf
Run the agent again to reset the fictitious dates to blanks

rowData not working as espected in repeat control

I have : <xp:repeat id="repeatColor" value="#{productcolors}"
var="rowData" indexVar="rownum" >
PROBLEM : rownum goes from 0 to the last correct value, but rowData is always the same
This repeat control is bound to a view "productcolors" , a view with a key on product code.
This view has a first column with the product code , ascending (for the key).
It also has a second and a third column with ascending multiple value fields.(second is framecolor, third is upholstery color)
The idea is that the repeat control goes through the different colors for the selected product, but it only shows the first one and does that the number of times (rownum increases correctly)that there are colors for the selected product.
EDIT :
So I have for example a product called "A" available in framecolors "1" "2" and "3"
When I am using the repeat control rownum changes from 0 to 2 but rowData is always the reference of framecolor "1". I don't know why rowData isn't changing.
When I use rowData.getUniversalID() I am getting 3 times the ID of the document containing the multiple value field with the 1 , 2 and 3 in it, which is I guess normal ? But how can I get a handle to those different values inside it ?
SECOND EDIT
I tried :
var testje:string = rowData.getUniversalID();
var db:NotesDatabase = session.getDatabase(database.getServer(),"product/colors.nsf");
var doc:NotesDocument = db.getDocumentByUNID(testje);
test = doc.getItemValueString("colorUpholstery");
The result is that "test" only holds the first item of the multiple value field "colorUpholstery" .
How is that possible ? I thought I would get the complete value of the "colorUpholstery" field ?
Maybe because I only have reader access(Publicaccess) to the colors.nsf database ?
It would be nice to see a little more code... like what's inside the repeat.. just to get a better feel for it to go along with your description of the Notes View.
rowData should be an XSPViewEntry... basically a NotesViewEntry... I suggest you first do something like rowData.getDocument().getUniversalId() to make sure it is iterating the documents correctly. I'm sure it is.
It sounds like you're trying to do something with a multi-value field.. are you also setting the view to use display multiple values as row entries? or whatever that setting is? That might get dicey if that's turned on. Not sure.
Again I'm not totally following what what the goal is but I would first test to make sure it is actually repeating the expected documents. then it's all about fine tuning.
EDIT: Ok... some thoughts based on your additional info:
I suspect that your problem is the use of the view setting "show multiple values as separate entries". Each is the same document really. So that's likely not helping you here. I'm still a little fuzzy on exactly what you want for the output. Is this from a "view page" of maybe products? a "form page" of a single product?
I ASSUME you want all the colors for a single product? And this is a lookup view right? so you're on your product "document" and now you want to list all the colors?
Assuming so...
Use SSJS and the object model. Do a lookup to find the SINGLE document that has the multi-value color field for your current product. then return to a repeat control something like:
lookupDoc.getItemValue("colorField")
I'm not 100% sure that's the correct syntax. The point is you can send a multi-value field to a repeat control and it will repeat it. Much easier then trying to use view tricks.
If your goal is to have a Repeat of multiple products.. and in side each "row" to show all the available colors then you're looking to have a nested repeat really... The outer repeat (outerData) to iterate over all the main products and inside that another repeat (innerData) for the colors. Inside that repeat code you use the "outerData" to get the multi-value field. Something like:
outerData.getDocument().getItemValue("colorField")
Assuming I'm understanding you correctly these are my suggestions.
I did do an example of nested repeats like this on an early NotesIn9. I believe it was this one: http://notesin9.com/index.php/2010/03/30/notes-in-9-show-14-repeats-repeated/
Maybe that will help.
Second Edit Response:
Based on the code you added you're using "doc.getItemValueString()" By design that will only get you the first value of a multi-value field. This is the same as saying in LotusScript:
doc.colorUpholstery(0)
or the less commonly used
doc.getItemValue("colorUpholstery")(0) ' I might have that wrong. I never really used it
Again if you want to make a list of all the colors I'd use a repeatControl and pass in:
doc.getItemValue("colorUpholstery") then your "rowData" for that repeat will be each value. I've seen others avoid the repeat and doing some javascript explode or implode type thing I believe. using "\N" or something as a separator for a new line. I just use a repeat. Easer for me to understand.
Again I THINK everything you need really is in NotesIn9 episode 14.

Playframework: Dynamic Search Fields

I need to implement a search dialog within play but don't know to solve this.
I have 3 integer fields in my database and want to search each of them with min and max values:
select * from office
where maxSeats <= maxParamFromPage
and maxSeats >= minParamFromPage
...
All fields are optional so if a user only enters the minParamFromPage all offices should be listed which are higher than this param. Now I have 3 params like maxSeats and I need to buildup my query dynamically based on the input parameters. I thought about replacing them with "0" or null when those are not entered but this is placed one to one in the sql query.
Can somebody help me on this?
Thank you!
You should used JPA Criteria API to construct your criterion based on the form values.
Refer this example

Translating strings postgres

I'm trying to translate 2 types of data using only postgres SQL
I've got a column "type" that may contains the kind of data.
type is a string column and may have "ACTUAL" or "OLD" values
+-type-+
+ACTUAL+
+OLD +
+------+
when I show the list with a lot of other joins I would like to show only "A" or "O" values
I couldnt find other way to do this than:
SELECT replace(replace(mytable.type, 'ACTUAL', 'A'),'OLD', 'O');
With that I can replace the text the way I need,
but I was looking for some more function using an array as parameter.
something like a cross-reference simple function:
translate(['ACTUAL','OLD'], ['A','O'])
Does anyone know a way to do this that doesn't use SQL views and neither needs another table like joining the results of this value with other table?
Thanks in advance,
Andre
I would use something like CASE...
SELECT
(CASE type
WHEN 'ACTUAL' THEN 'A'
WHEN 'OTHER' THEN 'O'
ELSE '?' END)
FROM
Using this method, you can return whatever you want based on whatever criteria you want, not just sub-stringing.

How can I make an InfoPath textfield within an repeating table auto increment?

Within my InfoPath form (which has to be loaded within a SharePoint Portal by the browser)I have a repeating table containing multiple fields. Now I would like to make the first textfield autoincrement starting by 1. How exactly can I do this?
I have already heard of a way by using the "count" function but this produces errors or in best case a static number which unfortunately does not count.
The function I have added for the field is "count(.) + 1"
Any suggestions?
Let's say your repeating group is called "item" and your autoincrement field is called "index". The default value of the index field should be
count(/my:myFields/my:item)
This should count correctly for you.
I suspect you really want position(). Count is just going to return the total count of nodes that match the xpath expression you give it.

Resources