Adding presence support to a window

To add presence support to a window, you will add several predefined fields to the window. Then you will add scripts to those fields.

Adding fields

To add the fields needed for presence support, complete the following steps:

  1. Add the PresenceChangeEventTrigger field.

Add the global field named PresenceChangeEventTrigger as a hidden field on the window. Set the following Object property for the field:

[spacer]

Editable

False


Set the following Visual properties for the field:

[spacer]

BackColor

Yellow

Visible

False


  1. Add Label_Presence fields.

Add an element of the global array field named Label_Presence_Button for each field for which presence will be tracked. For example, if two fields in the window will have presence tracked, add elements 1 and 2 of the Label_Presence global field. Set the following Object property for each field:

[spacer]

Editable

False


Set the following Visual properties for each field:

[spacer]

BackColor

Yellow

Visible

False


  1. Add the PB_Presence_Button fields.

Add an element of the global array field named PB_Presence_Button for each field for which presence will be tracked. For example, if two fields in the window will have presence tracked, add elements 1 and 2 of the PB_Presence_Button global field. Place the field to the left of the field for which presence is being tracked. Set the following Object properties for each field:

[spacer]

SetChangeFlag

False

TabStop

False


Set the following Visual properties for each field:

[spacer]

Appearance

2D Border

Border

False

Size-Height

18

Size-Width

18

Style

TextOnly


Attaching scripts

To add the scripts needed for presence support, complete the following steps:

  1. Attach a change script to the PresenceChangeEventTrigger field.

This change script is used to reset the presence fields for the window. The script handles the following cases:

If the name of the form or window contains spaces, be sure to enclose the name in single quotes. Otherwise, the presence fields cannot be accessed.


The following example shows this script for the Lead_Inquiry window in the sample integrating application.

local string form_name;
local string window_name;

{Specify the technical name of the form and window that contains the
fields for which presence is being tracked.}
form_name = "IG_Lead_Inquiry";
window_name = "IG_Lead_Inquiry";

case PresenceChangeEventTrigger
	in [-1]
		{Unregister all of the presence triggers for the window}
		call Unregister of form Dummy_Presence_Form, form_name, window_name, 1, Label_Presence[1], 'Salesperson ID', CO_INETADDRS_SALESPERSON, "", IG_PROD_ID;
	in [1]
		{Unregister a specific presence trigger for the window}
		call Unregister of form Dummy_Presence_Form, form_name, window_name, 1, Label_Presence[1], 'Salesperson ID', CO_INETADDRS_SALESPERSON, "", IG_PROD_ID;
end case;

  1. Attach a change script to each Label_Presence field.

This change script retrieves the SIP address associated with the entity, and registers the presence field. The following example shows this script for the Label_Presence field used for the Salesperson ID field in the Lead_Inquiry window in the sample integrating application.

local string form_name;
local string window_name;

{Specify the technical name of the form and window that contains the fields for which presence is being tracked.}
form_name = "IG_Lead_Inquiry";
window_name = "IG_Lead_Inquiry";

{Retrieve the SIP address for the salesperson and store it in the array element}
Label_Presence[1] = GatherSIP(CO_INETADDRS_SALESPERSON, 'Salesperson ID', "");

{Register the presence trigger for the field}
call Register of form Dummy_Presence_Form, form_name, window_name, 1, Label_Presence[1], 'Salesperson ID', CO_INETADDRS_SALESPERSON, "", IG_PROD_ID;

  1. Attach a change script to each PB_Presence field.

This change script performs the action the user chooses from the button drop list. The following example shows this script for the presence indicator next to the Salesperson ID field in the Lead Inquiry window in the sample integrating application.

local string convo_title;

{Build the title to use for any conversation}
convo_title = 'Lead Name' + CH_SPACE + CH_DASH + CH_SPACE + 'Lead ID';

{Perform the action that was chosen from the button drop list}
call Activate of form Dummy_Presence_Form, "", "", 0, Label_Presence[1], convo_title, PB_Presence_Button[1], "", "", "", IG_PROD_ID;

  1. Add presence support to the window pre script.

In the window pre script, you must register all of the presence fields for the window. The following example shows the code that was added to the window pre script for the Lead Inquiry window to register the presence fields.

{Clear and then register the presence fields for the window}
PresenceChangeEventTrigger = -1;
run script PresenceChangeEventTrigger;
run script Label_Presence[1];

  1. Add presence support to the window post script.

In the window post script, you must unregister all of the presence fields for the window. The following example shows the code that was added to the window post script for the Lead Inquiry window to unregister the presence fields.

{Unregister the presence fields for the window}
PresenceChangeEventTrigger = -1;
run script PresenceChangeEventTrigger;

  1. Add code to update presence when a different record is shown.

Each time a different record is shown, you must unregister the presence fields and then reregister them so they can be updated based on the new data being displayed. You will add code to do this in each place that can cause a new record to be displayed. Common locations for this code are the change script for the control field and the browse buttons for the window.

The following example shows the portion of code added to the browse buttons for the Lead Maintenance form in the sample integrating application to update the presence when a new record is displayed.

{Update the presence status}
PresenceChangeEventTrigger = -1;
run script PresenceChangeEventTrigger;
run script Label_Presence[1];

  1. Add code to update presence for individual fields (if required).

You may have presence indicators for fields that have their values set individually, such as by using a lookup or typing a field value. If the field value changes, you need to use the field change script to update the presence indicator for the field.

The following example shows the code that was added to the change script for the Salesperson ID field in the Lead Maintenance window of the sample integrating application. This code updates the presence status for the new value when the user changes the value of the Salesperson ID field.

{Update the presence status}
run script Label_Presence[1];


Documentation Feedback