Examples: AddCommand()


The following example is the IG_AddCustomerActions trigger processing procedure from the sample integrating application. This procedure adds two commands to the Customer card list Action Pane. The ExistsAsAction() function is used to verify that the commands haven’t already been added. Notice that after the commands have been added, the List_RegisterAction() function registers them.

inout ListObjState list_object;

local integer seq;
local integer nStatus;
local boolean exists;

{Is this the Customers list?}
if list_object:ListID = LISTID_CUSTOMERS then

	{Does the Contact History command exist for the list? If not, add it.}
	exists = ExistsAsAction(IG_PROD_ID,
		resourceid(form Command_IG_Sample),
		resourceid(command IG_Contact_History of form Command_IG_Sample),
		DYNAMICS,
		LISTID_CUSTOMERS,
		LIST_PRIMARYVIEWID) of form syListViewCmdBarObj;

	if exists = false then

		{Find the Remove Hold command}
		seq = FindCommandInCmdList(DYNAMICS,
			LISTID_CUSTOMERS,
			LIST_PRIMARYVIEWID,
			DYNAMICS,
			resourceid(form ListObj_Customers),
			resourceid(command CL_ModifyGroup of form ListObj_Customers),
			DYNAMICS,
			resourceid(form ListObj_Customers),
			resourceid(command Remove_Hold of form ListObj_Customers)) of form syListViewCmdBarObj;

		{If the command was found, add the Contact History command}
		if seq <> 0 then
			seq = seq + 1;
			nStatus = AddCommand(DYNAMICS,
				LISTID_CUSTOMERS,
				LIST_PRIMARYVIEWID, 
				DYNAMICS,
				resourceid(form ListObj_Customers),
				resourceid(command CL_ModifyGroup of form ListObj_Customers),
				seq, 
				IG_PROD_ID,
				resourceid(form Command_IG_Sample),
				resourceid(command IG_Contact_History of form Command_IG_Sample), 
				LISTACTIONPRIORITY_SECONDARY,
				LISTACTIONBTNSIZE_SMALL,
				""{caption}, 
				true{visible}) of form syListViewCmdBarObj;
		end if;
	end if;

	{Does the Update Contact Date command exist for the list? If not, add it.}
	exists = ExistsAsAction(IG_PROD_ID, 
		resourceid(form Command_IG_Sample),
		resourceid(command IG_Update_Contact_Date of form Command_IG_Sample), 
		DYNAMICS,
		LISTID_CUSTOMERS,
		LIST_PRIMARYVIEWID) of form syListViewCmdBarObj;

	if exists = false then

		{Find the Print Statements command}
		seq = FindCommandInCmdList(DYNAMICS,
			LISTID_CUSTOMERS,
			LIST_PRIMARYVIEWID,
			DYNAMICS,
			resourceid(form ListObj_Customers),
			resourceid(command CL_ActionsGroup of form ListObj_Customers),
			DYNAMICS,
			resourceid(form ListObj_Customers),
			resourceid(command Print_Statements of form ListObj_Customers)) of form syListViewCmdBarObj;

		{If the command was found, add the Update Contact Date command}
		if seq <> 0 then
			seq = seq + 1;
			nStatus = AddCommand(DYNAMICS,
				LISTID_CUSTOMERS,
				LIST_PRIMARYVIEWID, 
				DYNAMICS, 
				resourceid(form ListObj_Customers),
				resourceid(command CL_ActionsGroup of form ListObj_Customers),
				seq, 
				IG_PROD_ID,
				resourceid(form Command_IG_Sample),
				resourceid(command IG_Update_Contact_Date of form Command_IG_Sample),
				LISTACTIONPRIORITY_SECONDARY,
				LISTACTIONBTNSIZE_SMALL,
				""{caption},
				true{visible}) of form syListViewCmdBarObj;
		end if;
	end if;

	{Register the Contact History action}
	List_RegisterAction(list_object, command IG_Contact_History of form Command_IG_Sample, LISTCMDTYPE_SINGLESELECT, ACTION_CONTACT_HISTORY_ENCODED) of form syListObj;

	{Register the Update Contact Date action}
	List_RegisterAction(list_object, command IG_Update_Contact_Date of form Command_IG_Sample, LISTCMDTYPE_MULTISELECT, ACTION_UPDATE_CONTACT_DATE_ENCODED) of form syListObj;

end if;


Documentation Feedback