Solved

First occurrence of DBLookup

Posted on 2000-04-23
22
534 Views
Last Modified: 2013-12-18
Hi,
Does anyone know how to show the first occurrence of @DbLookup result in a field?

For example, in a keyword field, I have a @Dblookup formula and I want to display the first occurrence of the lookup result in the same field.

Does anybody know how to do it?

Thanks a lot in advance!
0
Comment
Question by:kspuea
  • 10
  • 4
  • 3
  • +3
22 Comments
 
LVL 2

Expert Comment

by:amit_dutta
Comment Utility
Hello kspuea,

If u want the first occurence of Dblookup then use the Dlookup formula inside a @Subset formula.
Example: @Subset(@Dblookup; 1)
This will return the first occurance. For the last occurance use -1 instead of 1 in the @subset parameter.

Hope this will serve ur purpose.
0
 

Author Comment

by:kspuea
Comment Utility
Adjusted points from 30 to 50
0
 

Author Comment

by:kspuea
Comment Utility
Thanks, amit dutta!
Maybe I didn't make myself clear.
I still need the rest of occurrences of my @DbLookup while showing the first occurrence without clicking on the keywordfield.

However, @Subset only return the first occurrence but not the rest too.


0
 
LVL 6

Expert Comment

by:ghassan99
Comment Utility
Put this @Subset(@Dblookup; 1) in the default value formula for the field.

-Gus
0
 

Author Comment

by:kspuea
Comment Utility
Thanks, ghassan99!
However, I need to reference a field (called Dept) for my DBLookup.
Thus, if I put the @Subset(@Dblookup; 1) in the default value event, an error occurs.

Here is my @DBLookup in the keyword field:
@If(@IsDocBeingEdited;@DbLookup( "" : "NoCache" ; "" : "" ; "ProfileByDept" ; Dept ; "ProfileFC" );@Unavailable)
0
 
LVL 6

Expert Comment

by:ghassan99
Comment Utility
what error r u getting?

I tried it works fine...

-Gus
0
 

Expert Comment

by:mkngau
Comment Utility
I think what ghassan proposed is correct. But you need to do some modification. Here is it:

@If(@IsDocBeingEdited;
    @subset(@DbLookup( "" : "NoCache" ; "" : "" ; "ProfileByDept" ;Dept ; "ProfileFC" );1)  
;@Unavailable)

you put this in the default value formula for the field, it should work. you know the 'default value formula for the field', right?

 
0
 

Author Comment

by:kspuea
Comment Utility
Yes, I know. But this formula works if the Dept field has a value already, right?

My workflow is as follows:
1) When user first creates the doc, all the fields are empty.
2) Then he needs to select the Requestor name, and the Dept will have values based on the Requestor field.
3) After that, the editable keyword field called "TCFC" should display the first occurrence of @DbLookup.

0
 

Expert Comment

by:mkngau
Comment Utility
you can check on this

http://www1.experts-exchange.com/Computers/Groupware/Lotus_Notes/Q_10186618.html

ghassan99 have solved for me last time.
It might match you case
0
 

Expert Comment

by:mkngau
Comment Utility
you can check on this

http://www1.experts-exchange.com/Computers/Groupware/Lotus_Notes/Q_10186618.html

ghassan99 have solved for me last time.
It might match you case
0
 
LVL 6

Expert Comment

by:ghassan99
Comment Utility
Which Notes version r u using?  I tried in R5, it works fine actually even if Dept is empty.

mkngau,
Lee how r u?:) Nice of u to jump in:)

-Gus
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:kspuea
Comment Utility
Hi Gus,
I'm using Notes v4.6.3 and your method doesn't work for my case.
0
 
LVL 5

Expert Comment

by:snocross
Comment Utility
What is the error message you are getting or is it just not returning a value?
0
 
LVL 5

Expert Comment

by:snocross
Comment Utility
Are you doing this through a web browser?
0
 

Author Comment

by:kspuea
Comment Utility
No, I'm doing it through a web browser.
It's in a Notes form.
I get this error message something as follows:
"Entry not found in index"
if I put the formula in the Default Value of the field.

And I get only first occurrence of the @DbLookup in the field, if I put the formula inside the "Choices" property of the keyword field.
0
 
LVL 5

Expert Comment

by:snocross
Comment Utility
Assuming I'm understanding you correctly I have got it to work:

Steps to recreate:

1) Create a keywords field called ReqName.  
- Make sure the field allows multi-values.
- Use formula for choices... I used a dblookup to return a multivalue text list of names.

2) Create a compute field called Dept which will show you all the departments the Requestor name belongs to.
- @If(ReqName != "";@DbLookup( "" : "NoCache" ; "yourserver" : "yourdb" ; "System Configuration" ; ReqName ; "Logging" );"")
- This field can eventually be hidden if you want it to be.

3) Create a third field that will display the first dept in the list.  I called my field FirstDept
- Use this formula: @Subset(Dept;1)

IMPORTANT:  For this to work without having to save the document (after you have selected a requestor) then you will need to select AUTOMATICALLY REFRESH FIELDS in the form properties/defaults options.

I hope this is what you're looking for.
0
 

Author Comment

by:kspuea
Comment Utility
Thanks, snocross. However, what I want to @Subset is the @DbLookup result in keyword field, not the Dept field.
I just need to use Dept field value to do the @DbLookup.
0
 
LVL 5

Expert Comment

by:snocross
Comment Utility
Ok, so what type of field is your DEPT field?  Is it editable (does the user just type a dept) or is it a keywords field (does the user pick a dept from a list) or computed (the dept is automatically put in the dept field)?
0
 

Author Comment

by:kspuea
Comment Utility
yes, it's a computed field.
0
 
LVL 3

Accepted Solution

by:
Joep8020 earned 50 total points
Comment Utility
I would do it like this:

Make the ReqName field computed when composed. In the value use the formula @PickList([Names]). Then make the Dept field also computed when composed.

Create a hidden computed field named TCFClist containing the formula (this is for performance reasons, you only have to do 1 dblookup this way):

tList:=@If(@IsDocBeingEdited;@DbLookup( "" : "NoCache" ; "" : "" ; "ProfileByDept" ; Dept ; "ProfileFC" );@Unavailable);
@If(@IsError(tList);"";tList)

This field should be below the DEPT field.

Finally in your TCFC field use this formula for your keywords:
TCFClist

and this one for your default value:
@Subset(TCFClist;1)

Hope this helps you

0
 

Author Comment

by:kspuea
Comment Utility
Comment accepted as answer
0
 

Author Comment

by:kspuea
Comment Utility
Thanks for your enlighten, Joep8020!
I did something like your method.
But I didn't create a new field to store TCFC. I just coded something in the Exiting Event of the previous field before the TCFC field. And it works for me, finally.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This is an old article, please see an updated version of this article, located here: http://www.experts-exchange.com/articles/23619/Notes-8-5x-Windows-7-Notes-info-and-tips.html
I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now