Solved

Profile Doc Read Fields

Posted on 2004-08-19
15
292 Views
Last Modified: 2013-12-18
I thought this problem was solved, but it's back and more of a problem.

I have multiple fields on the profile doc :

fldnameApprvAS
fldnameByupApprvAS
fldnameDoerAS            are 3 of them. To extract the value of these fields I pass the

value "AS" to the below function to 3 variables. "AS" is passed to this function in "stName".This, in theory, gives me the before mentioned three field names I need. I need to read these field names and get the text data stored in the field. Instead the value I get are the names of the fields.

I should mention I need to extract the field values, not override them.

Help.... The function code follows:

      Dim session As New NotesSession
      Dim db As NotesDatabase
      Dim prfdoc As NotesDocument
      Dim fldnameApprv As String
      Dim fldnameBkupApprv As String
      Dim fldnameDoer As String
      Set db = session.CurrentDatabase
      Set prfdoc = db.GetProfileDocument("frmProfile")
      fldnameApprv = "fldPrflAppvr" +  (stName)
      fldnameBkupApprv = "fldPrflBkupAppv" + (stName)
      fldnameDoer = "fldPrflDoer" + (stName)
      If prfdoc.getItem(fldnameApprv)(0)<> "" Then
            getProfile = prfdoc.getItemvalue(fldnameApprv)
      Else
            If prfdoc.getItemValue(fldnameBkupApprv)(0)<> "" Then
                  getProfile = prfdoc.getItemvalue(fldnameBkupApprv)
            Else
                  If prfdoc.getItemValue(fldnameDoer)(0) <> "" Then
                        getProfile = prfdoc.getItemvalue(fldnameDoer)
                  End If
            End If
      End If      
      
End Function

0
Comment
Question by:bobdraz
  • 8
  • 6
15 Comments
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 11845383
You could aswell continued on previous question and clarified it with the expert.

Anyway

Here you go..

     If prfdoc.getItem(fldnameApprv)(0)<> "" Then
          getProfile = prfdoc.getItemvalue(fldnameApprv)(0)
     Else
          If prfdoc.getItemValue(fldnameBkupApprv)(0)<> "" Then
               getProfile = prfdoc.getItemvalue(fldnameBkupApprv)(0)
          Else
               If prfdoc.getItemValue(fldnameDoer)(0) <> "" Then
                    getProfile = prfdoc.getItemvalue(fldnameDoer)(0)
               End If
          End If
     End If    

I just added index 0 to the getitemvalue function .. so that it will get the first value of the field

~Hemanth
0
 
LVL 24

Accepted Solution

by:
HemanthaKumar earned 500 total points
ID: 11845414
I believe you have to refine the function to return a variant/array of three values ...

          getProfile = prfdoc.getItemvalue(fldnameApprv)
          getProfile = ArrayAppend(getProfile, prfdoc.getItemvalue(fldnameBkupApprv))
          getProfile = ArrayAppend(getProfile, prfdoc.getItemvalue(fldnameDoer))

And the function should be declared to return variant

i.e. function getProfile as variant

And later loop thru the return value for any nulls and disregard.
 
0
 

Author Comment

by:bobdraz
ID: 11845629
I did add the index O and declared the function as varient and ran a another test with the degugger. It seems to fall through the nested If statement as if each field on the profile doc was null. I verified the fields on the profile doc are populated with names. I use these names for email purposes. I access this function from another function with the code:
                               
            If x <> "" Then
                  apr(k) = x
                  k = k + 1
                  aprname = getProfile(x)

In the debugger when I return to this fuction, aprname is still set to null. My code just doesn't seem to read the profile doc fields. - Help
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 11845796
There is a problem in your first if condition.. it is not getItem, it should be getitemvalue
0
 

Author Comment

by:bobdraz
ID: 11851898
I fixed the if condition to getItemvalue, but it still doesn't work. In the first if condition:

If prfdoc.getItem(fldnameApprv)(0)<> "" Then
          getProfile = prfdoc.getItemvalue(fldnameApprv)(0)


The string fldnameApprv contants the profile doc field name "fldPrflApprvAS"
The value "AS" was passed from the prior function.

In this function the string is build to contain the name of the field on the profile doc I want to get the value from.

 fldnameApprv = "fldPrflAppvr" +  (stName)

I put the string into:

If prfdoc.getItem(fldnameApprv)(0)<> "" Then
          getProfile = prfdoc.getItemvalue(fldnameApprv)(0)

I want the value of the profile doc field returned in "getProfile" to the prior function. It does not appear I am getting to the profile doc field..... Help
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 11852144
Again it is not getitem...

Check this line...If prfdoc.getItem(fldnameApprv)(0)<> "" Then

It should be If prfdoc.getItemVALUE(fldnameApprv)(0)<> "" Then
0
 

Author Comment

by:bobdraz
ID: 11852266
I apologize. I did fix the code as you instructed. I copied it back here incorrectly. Here's the actual code I just ran and I still can't get it to work. - help

Function getProfile (stName) As Variant
      Dim s As New NotesSession
      Dim db As NotesDatabase
      Dim doc As NotesDocument
      Dim fldnameApprv As String
      Dim fldnameBkupApprv As String
      Dim fldnameDoer As String
      Dim doer As NotesItem
      Set s = New NotesSession
      Set db = s.CurrentDatabase
      Set doc = db.GetProfileDocument("frmProfile")
      fldnameApprv = "fldPrflAppvr" +  (stName)
      fldnameBkupApprv = "fldPrflBkupAppv" + (stName)
      fldnameDoer = "fldPrflDoer" + (stName)
      
      If doc.GetItemValue(fldnameApprv)(0) = "" Then
      getProfile = doc.GetItemValue(fldnameApprv)(0)
      Else
      If doc.GetItemValue(fldnameBkupApprv)(0)<> "" Then
            getProfile = doc.GetItemValue(fldnameBkupApprv)(0)
      Else
            If doc.GetItemValue(fldnameDoer)(0) <> "" Then
                  getProfile = doc.GetItemValue(fldnameDoer)(0)
                  End If
            End If
      End If      
      End Function
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 11852343
Still you have got problem in this line...If doc.GetItemValue(fldnameApprv)(0) = "" Then

Should it be = or <> ?
0
 

Author Comment

by:bobdraz
ID: 11852350
The line

If doc.GetItemValue(fldnameApprv)(0) = ""  

was changed to an equal condition for a test. The result was the same.
0
 

Author Comment

by:bobdraz
ID: 11852379
It should be <>. I was running a test.
0
 

Author Comment

by:bobdraz
ID: 11852436
Could it be how I'm referencing the field names in the GetItemValue. For example; one of the fields on the profile doc is "fldPrflAppvrAS". I derive this value in the folling string:  

fldnameApprv = "fldPrflAppvr" +  (stName)

And the use it:

If doc.GetItemValue(fldnameApprv)(0) = "" Then
     getProfile = doc.GetItemValue(fldnameApprv)(0)

Am I missing a DIM somewhere??
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 11852491
There is a little confusion here

you mention the field names int he profile as
fldnameApprvAS
fldnameByupApprvAS
fldnameDoerAS            

And you construct different field names here

     fldnameApprv = "fldPrflAppvr" +  (stName)     .... Effective field name is - fldPrflApprvAS
     fldnameBkupApprv = "fldPrflBkupAppv" + (stName)     .... Effective field name is - fldprflBkuppvAS
     fldnameDoer = "fldPrflDoer" + (stName)     .... Effective field name is - fldPrflDoerAS


So what is the actual field name in profile ???

If you are not sure what you are getting.. then I suggest u to debug and inspect the profile doc field items !!
0
 

Author Comment

by:bobdraz
ID: 11852629
I apologize for the confusion. This should help. I'll restrict this to just 3 of the profile doc fields.

Profile Doc - field names are fldPrflAppvrAS, fldPrflBkupAppvAS and fldPrflDoerAS.

My first function( which works fine) determins the field names by passing the value "AS" to my getProfile function (described above and not working).

I append the "AS" into the following strings:

   fldnameApprv = "fldPrflAppvr" +  (stName)
   fldnameBkupApprv = "fldPrflBkupApprv" + (stName)
    fldnameDoer = "fldPrflDoer" + (stName)

This strings now hold the actual profile doc field names I need the value from.

    fldPrflAppvrAS
    fldPrflBkupApprvAS
    fldprflDoerAS

So, in the line     If doc.GetItemValue(fldnameApprv)(0) = ""

(fldnameApprv) is a string with field name of "fldPrflApprvAS" that I wish to get the value of.
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 11853388
Add some print statements so you see what it is doing...

     If doc.GetItemValue(fldnameApprv)(0) <> "" Then
         getProfile = doc.GetItemValue(fldnameApprv)(0)
         Print {Retrieved value '} getProfile {' for } stName " from approver field " fldnameApprv
     ElseIf doc.GetItemValue(fldnameBkupApprv)(0)<> "" Then
         getProfile = doc.GetItemValue(fldnameBkupApprv)(0)
         Print {Retrieved value '} getProfile {' for } stName " from backup field " fldnameBkupApprv " after failing field " fldnameApprv
     ElseIf doc.GetItemValue(fldnameDoer)(0) <> "" Then
         getProfile = doc.GetItemValue(fldnameDoer)(0)
         Print {Retrieved value '} getProfile {' for } stName " from doer field " fldnameDoer " after failing fields " fldnameApprv "," fldnameBkupApprv
     Else
         Print {No values found, should return blank value -> '} getProfile {'}
     End If    


I also restructured it to use elseif instead of nested ifs (same thing but a little cleaner style and faster), and explicitly provide an else for the last condition failing.

So, you shoud now see what the parameter was, what the fldname used, what value returned, and if it went through multiple tests, what the rejected field names were.

You shoud also run this through the debugger, and before it exits, expand doc>Items, and see if the fields you are examining 1) exist, and 2) have values
0
 

Author Comment

by:bobdraz
ID: 11853516
Thanks for the help. Actually, I have been running this through the debugger and the values do check out OK. I will add the print statements and restructure as you suggest. Again, thanks for your help.
0

Featured Post

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

Join & Write a Comment

Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

760 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

23 Experts available now in Live!

Get 1:1 Help Now