• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 230
  • Last Modified:

Modify code to populate fields

Hey Experts!

I have some script that I need to modify but am having a little trouble with it, here's the code:

Sub Click(Source As Button)
      Dim ws As New notesuiworkspace
      Dim uidoc As notesuidocument
      Dim view As notesview
      Dim doc As notesdocument
      Dim ldoc As notesdocument
      Dim db As notesdatabase
      Dim wstring As String
      Dim sarray(0) As String
      
      Set uidoc = ws.currentdocument
      Set doc = uidoc.document
      Set db = doc.ParentDatabase
      If Trim$(uidoc.fieldgettext("skey")) <> "" Then
            Set view = db.getview("AELFNAME")
            sarray(0) = uidoc.fieldgettext("skey")
            Set ldoc = view.getdocumentbykey(sarray,True)
            Call uidoc.fieldsettext("x_empno",ldoc.employeeid(0))
            Call uidoc.fieldsettext("x_lastname",ldoc.lastname(0))
            Call uidoc.fieldsettext("x_firstname",ldoc.firstname(0))************
            Call uidoc.fieldsettext("x_jobtitle",ldoc.title(0))
            Call uidoc.fieldsettext("x_phone",ldoc.extension(0))
            Call uidoc.fieldsettext("x_deptno",ldoc.deptno(0))
            Call uidoc.fieldsettext("x_deptname",ldoc.deptTitle(0))
            Call uidoc.fieldsettext("x_supervisor",ldoc.supervisor(0))
            Call uidoc.fieldsettext("x_superempno",ldoc.superEmpno(0))
            Call uidoc.fieldsettext("x_deptabbr", ldoc.deptabbr(0))
            
      End If
End Sub

What I need is to populate the x_firstname field with the nick name if it exist if not then populate it with the firstname, I know that in formula I can do it by virtue of @IF (nickname = "", firstname ; nickname) which works great in a view but how do I do this in this script?
0
padillrr
Asked:
padillrr
  • 2
  • 2
1 Solution
 
SysExpertCommented:
if ldoc.nickname(0))="" then

  Call uidoc.fieldsettext("x_firstname",ldoc.firstname(0))
else
 Call uidoc.fieldsettext("x_firstname",ldoc.nickname(0))
ENd IF

I hope this helps !

0
 
padillrrProject CoordinatorAuthor Commented:
I get an error on the first line of your code

if ldoc.nickname(0))="" then ************HERE! I placed the code under this line :Call uidoc.fieldsettext("x_lastname",ldoc.lastname(0))

  Call uidoc.fieldsettext("x_firstname",ldoc.firstname(0))
else
 Call uidoc.fieldsettext("x_firstname",ldoc.nickname(0))
ENd IF
0
 
SysExpertCommented:
Whoops
remove the extra )

if ldoc.nickname(0)="" then
0
 
padillrrProject CoordinatorAuthor Commented:
I missed that as well it works great thanks!
0
 
Sjef BosmanGroupware ConsultantCommented:
Just a suggestion: try to work with fieldgettext and fieldsettext as little as possible. Use NotesDocument.GetItemValue and NotesDocument.ReplaceItemValue instead.
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.

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