Link to home
Start Free TrialLog in
Avatar of captain
captainFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Lotusscript! Value for ERROR: Server error: Entry not found in index

Hi

I have a field which DBlookup a customer number from a view in a different DB
This works fine the field is a dialog list and set to editable, the view dialog for choices points to the correct DB and the field is returning the number OK. The field is mandatory.

I want to have validation that the field has been populated correctly via the Dialog Box so we don't get mispellings through Upper/Lower case and also that the user has not just entered garbled characters.

Obvioously when garbled stuff is entered the lookup returns the "ERROR: Server error: Entry not found in index" display but the user can still save the document.

The field Customer is called Customer, the field customer number is called CustomerNo.

We have a query save staetment script in the OLE script libary which is based on the MSDoclib.ntf template, I would like to know what value the "ERROR: Server error:..." error has if you want to express this as a condition in LS. What needs to go into my validation script below instead of the ???

If source.document.CustomerNo(0) = ??? Then
            Msgbox "You must enter a correct customer name!",0+16, "Windows Title"
            Call source.gotofield( "Customer" )
            Continue = False
            Exit Sub
      End If

Many thanks
Avatar of madheeswar
madheeswar
Flag of Singapore image

Place the @Dblookup code here.
It seems there is a problem with the dblookup code.
It is not getting the value which you passed as key and that's when u get the above error.
May be try using: (to avoid errors)
res:=@Dblookup("":"Nocache";"";"viewname";"key";"fieldname");
@if(@Iserror(res);"";res)
Avatar of captain

ASKER

Hi madheeswar
sorry you may have misread, the dblookup code is working, what I need is the Lotuscript code for the query above.

Or are you suggesting that I drop the LS and use formula in the vield validation for the Customer field?

thanks
Sorry for that.
Instead of this:
If source.document.CustomerNo(0) = ??? Then

use:
If source.document.CustomerNo(0) = "" Then
ASKER CERTIFIED SOLUTION
Avatar of Bill-Hanson
Bill-Hanson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Just noticed, I'm using @DbColumn.

You can easily modify this code to use @DbLookup.
Avatar of captain

ASKER

Hi guys

quick feedback, I am traveling at the mo so will look at this when I am back at my desk tomorrow.

Thanks so far
Avatar of captain

ASKER

Hi madheeswar

working through the your comment first, when I use the expression for empty then I get the " Variant does not contain a container" error and the form bails. As the field is computed I guess it does not report back the value "", hence my question re the value for this error.

Thanks anyway, worth a try, will test Bill's post now.

Avatar of captain

ASKER

Hi Bill

I am getting 'No Choices' error on Lookup, have populated
 REM {Data options};
      targetFieldName := "Customer";
      sourceViewName := "SLCustomers";
      sourceViewSelectColumn := 1;
      sourceViewReturnColumn := 2;
      sourceServer := "slms02";
      sourceDatabase := "SL\\Sl-Customer-Name.nsf";

Here is the automatic lookup on the customer number field which works so the column db and view names are correct:
@DbLookup("": "NoCache";"slms02":"SL\\Sl-Customer-Name.nsf";"SLCustomers";Customer;"SLCustNum")

What am I doing wrong?
Avatar of captain

ASKER

Hi Bill

DbColumn works, DbLookup doesn't, so reverting to DbColumn does the trick, final code has one amendment, as I want the first column to be displayed for selection and that value to be returned:


      REM {Data options};
      targetFieldName := "";
      sourceViewName := "";
      sourceViewSelectColumn := 1;
      sourceViewReturnColumn := 1;
      sourceServer := "";
      sourceDatabase := "";
     
      REM {Prompt options};
      promptTitle := "Category";
      promptMessage := "Select a category from the list:";
      promptError := "No choices are available.";
      promptMultiple := @False;
     
      REM {Get the choices.};
      viewLookup := @DbColumn("":"NoCache"; sourceServer : sourceDatabase; sourceViewName; sourceViewSelectColumn);
      @If(@IsError(viewLookup); @Return(@Prompt([Ok]; "Lookup Error"; promptError)); "");
      choiceList := @Trim(@Unique(viewLookup));
      @If(choiceList = ""; @Return(@Prompt ([Ok]; "No Choices"; promptError)); "");
     
      REM {Display the prompt};
      noSelection := 1;
      selection := @Prompt(@If(promptMultiple; [OkCancelListMult]; [OkCancelList]); promptTitle; promptMessage; @GetField(targetFieldName); choiceList);
      @If(selection = noSelection; @Return(""); "");
     
      REM {Lookup value from the return column};
      selection := @DbLookup("":"NoCache"; sourceServer : sourceDatabase; sourceViewName; selection; sourceViewReturnColumn);
      @if (@IsError(selection); @Return(@Prompt([Ok]; "Lookup Error"; promptError)); "");
     
      REM {Update the target field};
      @SetField(targetFieldName; selection);
      @Command([ViewRefreshFields])

Many thanks