HOWTO: Retrieving Contact Names from Schedule+ TasksLast reviewed: February 19, 1997Article ID: Q163802 |
The information in this article applies to:
SUMMARYWhen processing Schedule+ Tasks via OLE Automation, the only reference to the Contact information is the ContactItemID property. This article shows how to retrieve the Contact information based on that property.
MORE INFORMATIONThe methods below show different ways of processing Schedule+ Tasks. The method you use depends on whether you know that all of your tasks have Contacts associated with them.
Method 1The following works only if every task has a Contact. If you get the error, "Function argument value, type, or count is invalid," on the GetRows method call, then you know that not every task has a contact, so you have to process the tasks row by row instead, as shown in Method 2.
* BEGIN CODE oSched = CREATEOBJECT("SchedulePlus.Application") oSched.Logon mySched = oSched.ScheduleLogged myTasks = mySched.SingleTasks IF myTasks.Rows > 0 && Make sure there are tasks to process myContacts = mySched.Contacts aTasks = myTasks.getrows(100,"text","contactitemid") FOR x = 1 TO ALEN(aTasks,1) && process the rows in the array * The following line limits the Contacts table to the given * criteria: ItemId = <contactitemid from the task> myContacts.SetRestriction("itemid",aTasks(x,2),"==") oneContact = myContacts.Item ?"Task Description: ", aTasks(x,1) ?"Contact First Name: ", oneContact.GetProperty("FirstName") ?"Contact Last Name: ", oneContact.GetProperty("LastName") ENDFOR ENDIF oSched.Logoff * END CODE Method 2The following method processes every task in the Schedule+ Task table. It verifies that there is a contact associated with the task before attempting to retrieve the contact information.
* BEGIN CODE oSched = CREATEOBJECT("SchedulePlus.Application") oSched.Logon mySched = oSched.ScheduleLogged myTasks = mySched.SingleTasks myContacts = mySched.Contacts DO WHILE !myTasks.IsEndofTable oneTask = myTasks.Item ?"Description: ", oneTask.GetProperty("Text") * We must verify that there is a contact for the task; otherwise, * the GetProperty call will cause an error. IF TYPE('oneTask.GetProperty("ContactItemID")') = "C" * The following line limits the Contacts table to the given * criteria: ItemId = <contactitemid from the task> myContacts.SetRestriction("itemid",; oneTask.GetProperty("contactitemid"),"==") oneContact = myContacts.Item ?"Contact Name: " ??ALLTRIM(oneContact.GetProperty("FirstName")) + " " ??ALLTRIM(oneContact.GetProperty("LastName")) ELSE ?"Contact Name: No Contact For This Task" ENDIF myTasks.Skip(1) ENDDO oSched.Logoff * END CODE REFERENCESThe Microsoft Developer Network Library, January 1997.
|
KBCategory: kbinterop kbole kbhowto
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |