lotus notes, search data that equal to textbox - lotus-notes

I don't understand why my code is not allowed.
#If(#DbLookup("":"nocache";#DbName;"GPA";1)="GPnum";#Failure(#Command([FileSave])&#Command([CloseWindow]));#Success)`
Please help me. Thank you.

#If(#DbLookup("":"nocache";#DbName;"GPA";1)="GPnum"
your code should have 1 more parameter.
from help
#DbLookup( class : cache ; server : database ; view ; key ; fieldName ; keywords )
So you have "GPA" as view and then you need to specify Key and field/column you wish to return. Also for DbLookup I would recommend you to use [FAILSILENT] as keywords, in this case you will not need to check result for #IsError
However probably you just need to use #DbColumn instead of #DbLookup.
as I understood you need to verify if some value exists in database/view, try this code:
#If(#DbColumn("":"NoCache";#DbName;"GPA";1)="GPnum"; #Failure(#Command([FileSave]) : #Command([CloseWindow])); #Success)
or
#If(#DbLookup("":"NoCache";#DbName;"GPA"; "GPnum"; 1; [FAILSILENT])<>""; #Failure(#Command([FileSave]) : #Command([CloseWindow])); #Success)

Edit: I add a code for button action that save the current doc (see author comment below)
The editable field in which the user enters the value we check is called GPnum. A view "GPA" is sorted by its first col an display GPnum value.
t:=#DbLookup("":"nocache";#DbName;"GPA"; GPnum ; 1 ; [FailSilent] );
#If(#IsError(t) ; #Prompt([Ok]; "DB has a problem:";#Text(t)) ;
t = "" ; #Do(#Command([FileSave]);#Command([CloseWindow])) ;
#Prompt([Ok] ; "unable to save" ; "The key already exists") )
original response
t:=#DbLookup("":"nocache";#DbName;"GPA"; #ThisValue ; 1 );
#If(#IsError(t) ; #Failure("DB has a problem:"+#Text(t)) ; t = "" ; #Success ; #Failure("The key already exists") )
If you use #failure/#success you MUST be in an editable field in a form (validation).
As I understand you check that your value does not ALREADY exists.
so:
first add #thisValue as the key you search in the DBLOOKUP,
as told above DBLOOKUP could return an error thus check #isError(t)
second failure just BLOCK the validation of the form, I never tried (an it doesn't make sense) to make it save the form
Hope it helps

Related

Hybris hide orders from display in backoffice with particular statuses

As per requirement, I need to not list in backoffice the Orders with CANCELED and FAILED status for all the employees except Admin, is there any way to modify the backoffice logic in order to not show the orders with particular statuses?
Achieved using SearchRestriction:
INSERT_UPDATE SearchRestriction; code[unique = true] ; name[lang = en]; restrictedType(code); principal(uid) ; active; generate; query
; order_status_estricted ; ; Order ; vendoradministratorgroup ; true ; true ; {status} IN ( {{ SELECT {os.pk} FROM {OrderStatus as os} WHERE {os.code} NOT IN ('CANCELED') }} )
You can use Flex Search Restriction for this. Restrictions automaticly adding where conditions to every flex query by item type. Also you can use session variables in this restrictions.

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 )

Why GET Method data not enter to database in one same page

I want to get id data to enter value to database
First Script, it's work.
But in second script not work.
This is my first script
<?php
include 'connect.php';
$id_event=$_GET['id_event']; //it's work
$assign="SELECT * FROM event where id_event='".$id_event."'";
$show_data=mysql_query($assign);
while($row=mysql_fetch_row($show_data))
{
?>
This is my second sript
$id_event=$_GET["id_event"];
$track_id = $_POST["track_id"];
case "upload":
$action = "upload";
$values = "'".$track_id."','".$id_event."'"; //this is the problem
$field = "track_id,id_event"; //$id_event not enter to database
Maybe you need to use $_POST['id_event'] instead of $_GET['id_event']

#dbcolumn in session.evaluate in xpages

I am trying to execute this code for a listbox but its not working, this gives me the error 500. If i directly write the #formula in listbox it works fine.
return session.evaluate("#DbColumn(#DbName(), \"viewName\", 1)").elementAt(0)
but if i write below code it works fine.
return session.evaluate("#Unique").elementAt(0);
I am working in xpages on Lotus Notes 8.5.3
You receive a 500er Error because the #DbColumn for SSJS has a parameter less than the "original" #DbColumn-Version which will be executed if you are using the evaluate method.
For XPages, the option for caching and class got lost.
This is the syntax for the evaluate statement:
#DbColumn( class : cache ; server : database ; view ; columnNumber )
This is the XPages syntax:
#DbColumn( server : database , view , columnNumber );
And you have to use the native Notes #Formula syntax, f.e. use semicolons instead commas.
session.evaluate works with original #Formula syntax, not with SSJS one.
So use #DbColumn( ""; #DbName; "view", column ) instead.
Here is the solution:
In SSJS you can code the following directly...
#DbColumn(#DbName(),"viewName",1)
If you want to do the same using the session.Evaluate(), then you can try the following.
//#DbColumn(#DbName(),"viewName",1) --> in SSJS
//#DbColumn( class : cache ; server : database ; view ; columnNumber ) --> in Formula using Evaluate
var colValues = "#DbColumn(\"\":\"\";" + #DbName() + ";\"viewName\";1)";
print ("colValues[0]" + colValues[0]); // will print #DbColumn( "":""; ServerName ; viewName; 1)
print ("colValues[1]" + colValues[1]); // will print #DbColumn( "":""; DatabaseName; viewName; 1)
return session.evaluate(colValues[1]) // It will return the expected value in listbox
Because #DbName() will return both the server name and the database name. Whereas we need only the database name. This is only for the current server. For different server we need to specify the server name. I hope this will help...!!!

Obtaining text from a QListView

I have a pointer to a third party QListView object, which is simply displaying rows of text. What is the best way of getting a hold of that string of text?
The model, accessible by QListView::model(), holds the items. You can do something like this:
QListView* view ; // The view of interest
QAbstractItemModel* model = view->model() ;
QStringList strings ;
for ( int i = 0 ; i < model->rowCount() ; ++i )
{
// Get item at row i, col 0.
strings << model->index( i, 0 ).data( Qt::DisplayRole ).toString() ;
}
You also mention you would like to obtain the updated strings when text is written - you can do this by connecting the model's dataChanged() signal to your function that extracts strings. See QAbstractItemModel::dataChanged().
You can ask the QListView object for its root QModelIndex and use that to iterate over the different entries using the sibling/children methods. You can access the text associated with each index by calling the data method on the index with the role specified as the Qt::DisplayRole.
For more details see the following documentation:
QAbstractItemView - parent class to QListView
QModelIndex

Resources