Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 650
  • Last Modified:

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
0
captain
Asked:
captain
  • 5
  • 2
  • 2
1 Solution
 
madheeswarCommented:
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)
0
 
captainAuthor Commented:
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
0
 
madheeswarCommented:
Sorry for that.
Instead of this:
If source.document.CustomerNo(0) = ??? Then

use:
If source.document.CustomerNo(0) = "" Then
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Bill-HansonCommented:
You just want to validate the field value based on the valid choices returned by the lookup, right?

Here is what I do:

(1) Don't use an editable field, Use "Computed When Composed" with an initial value of "".  But this means that you can't use the Dialog List field type since the entry helper button will not work for "Computed When Composed" fields. So...
(2) Change the field type to "Text"
(3) Create a button near the field that prompts the user for the choice.  See code below.

I like this solution better that using "Dialg List" fields because I can control the field better and I can provide the same user interface regardless of whether the user is acessing the form via the Notes Client or a web browser (ajax in browser).

Try this code behind your button.  Just fill in your settings in the "Data Options" section:

      REM {Data options};
      targetFieldName := "";
      sourceViewName := "";
      sourceViewSelectColumn := 1;
      sourceViewReturnColumn := 2;
      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])
0
 
Bill-HansonCommented:
Just noticed, I'm using @DbColumn.

You can easily modify this code to use @DbLookup.
0
 
captainAuthor Commented:
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
0
 
captainAuthor Commented:
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.

0
 
captainAuthor Commented:
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?
0
 
captainAuthor Commented:
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
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now