Microsoft KB Archive/163802

= How To Retrieve Contact Names from Schedule+ Tasks =

Article ID: 163802

Article Last Modified on 7/1/2004

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q163802



SUMMARY
When 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 INFORMATION
The 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 1
The 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 = 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 2
The 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 = 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

