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?
padillrrProject CoordinatorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

if ldoc.nickname(0))="" then

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

I hope this helps !

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))
 Call uidoc.fieldsettext("x_firstname",ldoc.nickname(0))
remove the extra )

if ldoc.nickname(0)="" then

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
padillrrProject CoordinatorAuthor Commented:
I missed that as well it works great thanks!
Sjef BosmanGroupware ConsultantCommented:
Just a suggestion: try to work with fieldgettext and fieldsettext as little as possible. Use NotesDocument.GetItemValue and NotesDocument.ReplaceItemValue instead.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.