Lotus Notes: Controlling input on multi-value fields - lotus-notes

I have been using multi-value checkbox field. Now I want to disable some of the checkboxes depending on criteria. For example if field A has value "no license" then disable field B's checkbox with value "car" but leave values "bike" and "train" available for user to select.
Having all the values in the same field would make handling the checked values easier but is it possible to modify multi-value field to work like that?

You need to compute the values allowed in the multi-value check box field based on the value of FieldA.
#If(FieldA = "No License"; "Bike":"Train"; "Car":"Bike":"Train")
You then need to set properties on the Checkbox field like this:
And on FieldA like this:
This will refresh the field choices for the checkbox whenever the value in FieldA changes

There is no way to selectively disable single values from checkbox. You can just remove the option completely so that it cannot be selected anymore.
So instead of just typing the values for the checkbox, use a formula to calculate them like:
#If( fieldA = "no license" ;
"bike" : "train" ;
"car" : "bike" : "train" )
The formula could be as complex / simple as you want. e.g. something like:
_licenseNeeded := "car" : "taxi" : "motorbike";
_other := "bike" : "train";
#Trim( #If( fieldA = "no license" ; ""; _licenseNeeded ) : _other )

Related

Label gets selected on clicking enter key in the tabulator cell

I have a js fiddle to show the issue that I am facing.
Tabulator 'email' column has freetext set to true to allow the user to set the value of the cell to a free text entry as follows:
editorParams:{
values:{
"steve#boberson.com":"steve",
"bob#jimmerson.com":"bob",
"jim#stevenson.com":"jim",
"harvy#david.com":"Harvy",
"ken#thompson.com":"Ken",
"denny#beckham.com":"Denny"
},
freetext:true,
searchFunc:function(term, values){
console.log("term and val "+term +" \n"+values);
var matchedEntries = {};
var matchFound = false;
for(var key in values) {
if(key.includes(term)){
matchFound = true;
matchedEntries[key] = values[key];
}
}
if(matchFound){
return matchedEntries;
}
else{
return {term: term};
}
}
}}
Select one of the values from the selector list displayed, say steve, value being 'steve#bobberson.com'.
Then after the value is selected, click on the same tabulator cell, the value displayed suddenly changes to the label.When user clicks enter key now, the label is selected instead of the value,.ie. steve will be displayed instead of steve#bobberson.com
If this is not a bug, how do I make sure that the value steve#bobberson.com remains selected after clicking enter. This is because freetext option is set to true in the editorParams of the column
Attached a gif showing the issue
That is not a bug,
With freetext enabled, users are able to enter any text they like in that field and it will be saved which is exactly what is happening in the example
If they select the email address again from the list then it is correctly saved.
It is an either/or scenario, you can either restrict the users to selecting specific values from the list OR you can allow them freetext in which case anything goes.
If you want a different behaviour then you can always build a custom editor that works in the way you want. Checkout the Custom Editor Documentation for more information

Clearing previously set value from Selector Editor

New to Tabulator, it's awesome! Have an issue on a Select editor. I am populating from a AJAX feed from API/DB. But my values don't have a "none" option. So I need to be able to clear the current value to "unselect" it. Eg set the DB value back to Null / None.
I can't see a way to do that on the Select editor? What's the most efficient way to clear the current value.
You should add a blank entry to your values object in the editorParams property of the column definition
{title:"Gender", field:"gender", editor:"select", editorParams:{
values:{
"":"", //clear cell value
"male":"Male",
"female":"Female",
}}
},

Kentico Admin - Dynamically Change and SAVE Field Name, Value and Label

For a custom page type, I have a multiple choice form filed as seen in image 1 and 2. I was able to set it up (using jquery) so that when I click on other checkboxes belonging to a another field, the checkbox Label and value of this field is changed accordingly as seen in image 3 - 'Author1', 'Author2', 'Author3' were replaced with something else.
The problem is when I hit the Save button, all of my new label/value are not Saved, but the checkbox value and label return to its original value.
Is there a way to make it so that these checkboxes can accept new value and the new value can be saved. Thanks!
Where does authors values come from? Database? You should be able to use SQL query as data source for multiple choice control. This will allow you to store actual values into database whenever you save a page on the Form tab.
So the idea is to load actual values, replace them with 'AuthorN' and change back to original value when checked.
I've set up an example which might help you. I've created a form with three fields:
FirstAuthor
Type: Integer
Form control: Radio buttons
Data source: SQL Query (select userid,username from cms_user)
Has depending fields: true
SecondAuthor
Type: Integer
Form control: Radio buttons
Data source: SQL Query (select userid,username from cms_user)
Has depending fields: true
OrderedAuthors
Type: Text (1000)
Form control: Label
Default value: {% (if(firstauthor>0) { GlobalObjects.Users.Where("userid="+firstauthor)[0].UserName } else {""}) + ", " + (if(secondauthor>0) {GlobalObjects.Users.Where("userid="+secondauthor)[0].UserName} else {""} #%}
Depends on another field: true
I guess you have a list of authors somewhere in the database so you can just replace CMS_User table with your table. Then all you need to do is to adjust the macro in the third field to give you results you want.

Can I apply a filter dynamically to List lookup on Nintex Forms 2013?

I have a requirement wherein I need to filter the List lookup dynamically. My list has a column called category that can either contain value 'A' or 'B'. Then there is a field -'Selection' on the Content type that can either take value 'A' or 'B' or 'All' . If its 'A' I need the List lookup to take rows where category = 'A' , same goes for'B'. However if the 'Selection' is - 'All' then I need to display all the items from the list.
I was thinking of filtering the List lookup for the column - 'Category' . But the problem is as I am on a content type form , I do not have any variables that can be set dynamically.
I can not use the Filter by control mapped to 'Selection' as the it does not work when the selection is 'All' (There is no value called 'All' under category in the list).
I tried using a calculated value that operates on a formula and tried using it in Filter by specific value in List lookup , but the filter doesn't work as the list lookup loads before the calculated value on form load and hence the calculated value is always empty for the filtering.
Is there any way I can achieve this functionality.
Thanks in advance
I have thought of two solutions to this problem.
Have 3 separate list lookup controls that are laid over top of each other. Filter one by A, one by B, and let one have no filter. Then create rules to show the one with the filter you want to show, and hide the others. To save the value, you'd have to use JavaScript to copy the value from the list lookup to a hidden text box when one of the controls changes value. This solution isn't great and gets worse if you have more options...but it works.
You can use JavaScript to filter the list based off the Selection. This is a little more tricky, but you wouldn't need more lookup controls for more options. You would need only 2 list lookups no mater how many options you have for Category/Selection. You need one that shows the info that you want the user to chose from (unfiltered) and the other is from the same list, and same view, but the column should be the Category column ( you can hide this lookup with javascript). This is the code I used to get what you are describing.
//get the original html to 'reset' the dropdown after a change
var originalTitle = NWF$("#" + title).html();
//when the selection changes
NWF$("#" + selection).change(function () {
//put the original html in the dropdown to check all the options
NWF$("#" + title).html(originalTitle);
//get the new value of the selection
var choice = NWF$("#" + selection + " :checked")[0].value
//if choice is all then we are done because the original html is in the dropdown again with all the options
if (choice == "All") {
return;
}
//create the array where you will store the ids of the options that match the choice
var filteredIds = [];
//for each option in the category drop down, see if the text matches the choice (this is your filtering)
NWF$("#" + categoryDD + " option").each(function (i, n) {
//if the text of the option matches the choice add the id to the array.
if (n.text == choice) {
filteredIds.push(n.value);
}
});
//initialize string of html
var filteredTitlesHTML = ""
//for each of the ids in the list, get the option html with that id from the title dropdown and add it to the resulting HTML string
NWF$(filteredIds).each(function (i, n) {
filteredTitlesHTML += NWF$("#" + title + " option[value = '" + n + "']")[0].outerHTML
})
//put the html in the dropdown to show only filtered values
NWF$("#" + title).html(filteredTitlesHTML);
})
You can see in the picture the javascript variable names I gave the controls to use the javascript I have provided.

How to associate id and its value in Combobox Domino designer(lotus script)

I am new to Domino designer and lotus script,
I have a form ,which has a combobox ,In combobox I have a formula for combobox:
(#DbColumn("" : "NoCache"; ""; "myview"; 2)
now I want to associate the ID and its name
Example : id :1 name(to display in combo) :Benz
id :2 name : Fiat
id :3 name : Yamaha
now my combobox must display only fiat,yamaha,benz but the corresponding id must be saved (not the name)
currently I'm displaying only names and saving names(I want to link it to id)
How can I achieve this ?
Your view needs to contain the values in format Name|ID (this is a pipe sign) in order to achieve what you want.
Column values:
Benz|1
Fiat|2
Yamaha|3
Response to your comment: Best practice (performance- wise) is, to create a separate column in your view with the formula Name + "|" + ID (you can hide it, if you use the view for users AND DBColumn, what would be bad practice by the way).
if you don't want to do this, then your formula could look like this:
_names := #DbColumn("" : "NoCache"; ""; "myview"; 2);
_ids := #DbColumn("" : "NoCache"; ""; "myview"; 1);
_names + "|" + #Text(_ids)
You REALLY should take a training in Lotus Notes Design, as these are all basics, if you once understood how Notes works.
The formula above is bad in a lot ways:
Usage of "NoCache" is a real performance- killer. Don't do it in big applications
doing two lookups instead of one doubles your response- times
Every lookup HAS to have an error handling, otherwise your form will not open anymore, if there is an error in it.
If the return of your DBColumn is >32k of data (large lists) this whole thing will fail due to field restrictions in Lotus Notes
A "best practice" way to do this (ignoring the possible 32k error) would be:
Create a view with a (hidden) third column with formula Name + "|" + ID
Use this code:
_view := "myview";
_col := 3;
_lkp := #DBColumn( "" : "Cache" ; "" ; _view; _col );
#If( #IsError( _lkp ) ; "" ; _lkp )

Resources