We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Modify code to populate fields

Ray Padilla
Ray Padilla asked
on
Medium Priority
241 Views
Last Modified: 2013-12-18
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?
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2007

Commented:
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 !

Ray PadillaIT  Director

Author

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
CERTIFIED EXPERT
Top Expert 2007
Commented:
Whoops
remove the extra )

if ldoc.nickname(0)="" then

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Ray PadillaIT  Director

Author

Commented:
I missed that as well it works great thanks!
Sjef BosmanGroupware Consultant
CERTIFIED EXPERT

Commented:
Just a suggestion: try to work with fieldgettext and fieldsettext as little as possible. Use NotesDocument.GetItemValue and NotesDocument.ReplaceItemValue instead.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.