xpages default value for combobox - xpages

I found this : Xpages Date Time Picker field defaults to today's date
I tried adding return null as default value for my combobox, but it still returns the first item from the list.
I also tried adding a formula item: #Text(""), but even if the default value is blank, it appears also as an item for the combobox.
Please help, thanks for your time.

One thing I do often for defaults.. and I forget if I do this for Comboboxes or not. But I'll bind the control to a viewScope variable. Then in beforePageLoad I'll set that viewScope variable to "" basically. I find this works better then the "default" option on the pretty properties pain. Maybe you want to give that a try.
In THEORY if that works then it will be blank to begin with.. but once it's changed you might probably can't put it BACK to blank. In order to to that you'd need to have a blank option at the top of your values list.

I am sure that there is a better way to do this, but....
I always use a normal item ojbect with one single space written in as the label and value. Under that I put my calculated values. Then for the default value, I put " ". It might not be pretty, but it gets the job done. When I read the value, before asking if it is empty, I just use #Trim() to make sure that it is indeed a real value.
Of course you could make the label a single white character space with a value "empty" and then use "empty" as your default value. The label would then be a single white space character.

Related

In a Notes field with a dialoglist, how can I display a blank as "None" for example?

I have a field where Yes and No are the valid selections in the dialoglist, the valid values for the field are setup with Synonyms like this Yes is Y and No is an empty value/blank/nothing.
Yes|Y
No|
When the document is saved this the field selection of "No" and re-opened how can I get the form field to display the word "No" when the field is blank?
It's not possible to accomplish that just with an alias definition.
You could work with two fields to get an empty field for "No":
Your current field let's say "TestUI" of type dialog list would have the choises
Yes|Y
No|N
and an additional computed text field "Test" with the formula
#Replace(TestUI; "N"; "")
would replace the "N" with an empty string.
You can avoid the two field solution by using a PostOpen formula:
FIELD MyDialogList := #If(MyDialogList="";"No";MyDialogList);
#All
P.S. I'm not sure what your intention was here, but this is actually not a bad way to deal with the case where you're adding a new field to an old form and you don't want to have to run an agent to add the new field to all previously saved documents. Since formulas just treat missing fields as empty strings, the #If will work as expected.
It seems like you've run into an edge case and you probably will need to assign some value as the alias to "No".
If it is really important to have the value be blank when a user selects No, you could create a second computed field that maintains the alias values. Assuming your dialog list field is called "YesNo", your computed field's formula could be:
#If(YesNo = "Yes"; "Y"; "");

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.

#ReplaceSubstring doesn't display value as expected

I have this formula in one of the columns in my view in Lotus notes database. However, it does not change the value of the field "EmployeeName" in the view and still displays the original name.
Example:
Original value: Franco Martínez, José Ramó
Expected output: Franco Martinez, Jose Ramo
value1:="i";
value2:="e";
value3:="o";
optionList := value1:value2:value3;
aliasList := "í":"é":"ó";
#ReplaceSubstring(#Text(EmployeeName); aliasList; optionList)
As the formula is absolutely correct, the issue has to be somewhere else.
You already checked, that the field is summary, so this cannot be the issue.
Please check the programmatic name of the column (last tab in the properties):
Does it happen to match another column in the same view or is it probably "EmployeeName"? Then just remove the name, it will be repopulated by a new unique name.
Explanation:
Duplicate programmatic names mean, that both columns show the same value, and the formula of the second columnn is never executed. If there is a Fieldname in the name of the column, then it will always show the value of that field, no matter what the formula sais.
Another explanation could be that "í" <> "í"... Probably one of them is the representation of another Unicode- Character and just happens to "look" like the other one... You can check this using a button or agent that just #Prompts the value after replacesubstring, or copy the content of the field into a Hex- Editor...
You could also try the #Ascii() - #Function to convert to ascii without having to replace characters.

ListBox Multi-Value String to Object

I have a ListBox where I need to restrict the number of options selected to two. I'm using 8.5.2 so cannot use the SSJS custom validator, but I can use a Java validator. The Java validator received the submittedValue as a comma-separated String.
The problem occurs if a value contains a comma. In that case, if I split the submittedValue String on commas, my code will think more options have been selected than actually have been.
When the value is written back into the underlying Notes Document, the conversion to getValue() has correctly mapped values. So if getSubmittedValue() was a single option from the ListBox that contained a comma, getValue() gives me a single element rather than two elements.
My query is how to reproduce the getSubmittedValue() to getValue() conversion, to correctly work out how many options have been selected.
Paul, you actually can control the commas. The option has a display string and a value. You could substitute the comma for e.g. # and later before saving it back check if you have a # at the same position the display values have a , and save it then.
It's a lot more work - so not smart.
The other option: take the possible values out one by one:
sort them by size, longest first (this way you avoid having a value that is contained in another value to screw up (e.g. "Red boat" vs "boat"
take them out of the return string (if removal worked, then you have one, stop when you hit the 3rd)
.... but probably the easiest on is to do that in a little client side JavaScript counting the checked=checked values

How to check more than 5 fields under action rule condition in infopath 2010

I am working on an infopath 2010 form/view based on a list.
I have 7 separate check box fields that I want to check through a rule under submit button that at least one of them should be selected.
Trying to do this and check for the condition, it is allowing me to check a maximum of 5 fields at a time.
How can I check at least one of these 7 check boxes is selected before submitting the data?
You can overcome this by changing your last condition to "The expression" and use "and" or "or" as needed to create your compound condition. So, for example, if you need to make sure both field1 and field2 are not blank, you'd use the expression:
my:myFields/my:field1 != "" and my:myFields/my:field2 != ""
If you need help figuring out the correct syntax for your expression, first set up the condition using the drop downs (for example, select field1 in your first drop down, then "is not blank" in your second drop down), then change the first drop down to "The expression" -- whatever your condition was will auto populate into the box for the expression. Paste that into a text editor, and then do the same for the rest of your conditions. Add and or or between them as needed, and you have your expression!
Source: http://www.infopathdev.com/forums/p/14871/52819.aspx
I had a similar issue and avoided using "The Expression" option because I had so many conditions to check before allowing a user to submit the form for certain scenarios, and it would have been very tough to debug and troubleshoot. I also considered Glen's sum-based solution because it made troubleshooting difficult as you can't really tell which condition is missing, and you can't perform logical checks on what's been selected or filled-in properly.
My solution was to set up a text CheckStatus field and a numeric CheckStatus-Value field. Rules on tested fields would add values to the CheckStatus field when the needed conditions were met. And when the CheckStatus-Value field hit the “magic number” (6 in the example below), then I would allow the user to submit the form. As an example, the CheckStatus-Value and CheckStatus fields are shown below, but would be hidden when the form is ready for production use:
CheckSum-Value & CheckSum fields
Then for every desired field, I assign a unique letter from “A” to “Z”, or from “a” to “z”, or from “0” to “9”, and test for the desired condition. In this way you could test for up to 62 concurrent conditions, tho that would be a bit crazy 😊 Every time the CheckStatus field changes, a rule runs to count the number of values and update CheckStatus-Value:
Update CheckSum-Value field
IF the condition is True AND the CheckStatus field does not already contain the unique letter/number assigned to that field, then I add the assigned number/letter (using the concat function) to the CheckStatus field. If a blank value is a valid value under specific conditions then I add the letter/number for the field when that condition is met, so a ready-to-submit form always has the same value in the CheckStatus-Value field. (If a valid value is changed to a different valid value, ensure the letter/number is only added ONCE to the CheckStatus field.)
Add value A to CheckStatus field
 
IF the condition is False, then I remove the assigned number/letter (using the translate function) from the CheckStatus field.
Remove value A from CheckStatus field
IF the field being tested (Field-A) is dependent on another field (Field-B), I also add the Field-A rule to Field-B, so the user does not have to touch Field-A to update the CheckStatus. Be careful when copy-pasting the rules; remember InfoPath will change field names automatically! I also added the “’Add-x”’ rules to the Form Load rules (on the Data tab) to update CheckStatus every time the record is loaded.
Hope this helps!
-Steve
Here's an idea: Use an integer field and put a rule on each of your 7 checkboxes that adds 1 to the field. Then your final validation rule just needs to be sure the integer field is greater than zero
(Better also have a rule to subtract 1 if a box is unchecked after being checked.)
-Glen

Resources