How To Retrieve Contact Names from Schedule+ Tasks

Article translations Article translations
Article ID: 163802 - View products that this article applies to.
This article was previously published under Q163802
This article has been archived. It is offered "as is" and will no longer be updated.
Expand all | Collapse all

On This Page

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 = <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 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 = <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
				

REFERENCES

The Microsoft Developer Network Library, January 1997.

Properties

Article ID: 163802 - Last Review: February 24, 2014 - Revision: 3.2
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
Keywords: 
kbnosurvey kbarchive kbautomation kbhowto kbinterop kboop KB163802

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com