?
Solved

Profile Doc Read Fields

Posted on 2004-08-19
15
Medium Priority
?
298 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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
You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

719 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