Logging action status

Since actions can be performed on multiple items marked in the list, it’s important to keep track of the status of each individual action and display the results for the user. Each list in Microsoft Dynamics GP has a Message Bar that is used to display the results of the actions performed on the list items.

Within the script that processes an action for a list, you must do the following:

Use the ActionStatus_LogError() function of the syListObj form to log the details of each error that occurred when performing actions on list items. This function takes several parameters that you supply to provide details about what failed for the specific item. These details are displayed in the Status Message Detail window in Microsoft Dynamics GP.

After all of the marked items in the list have been processed, call the ActionStatus_LogActionComplete() function of the form syListObj to indicate that the logging action is complete. The total number of successful and failed operations are passed as parameters to this function.

If the action being processed is a multi-select action, you must call the List_MultiSelectActionCompleteEvent procedure to indicate that all of the items have been processed. If you don’t use this function, the list will remain in the “processing” state.

The data for each action status item is stored in the sy07250 table in the current company’s database. As you log action status, you may want to see what has actually been logged in this table.

The following example is a procedure that performs the Update Contact Date action for the Customer card list. It processes each customer marked in the list, keeping track of the number of customers successfully processed. Any processing errors are logged using the ActionStatus_LogError() function.

inout ListObjState list_object;

local ListStatusLineUserDefData UserDefData;
local long ErrorStatus;
local integer SuccessCount;
local integer FailureCount;
local reference ListTableReference;
local integer ListTableIndex;

{Clear the status counts}
SuccessCount = 0;
FailureCount = 0;

{Use the table reference from the list object to find which Customers
 are selected in the list.}
ListTableReference = GetMarkedRecordsTableRef(list_object) of form syListObj;
ListTableIndex = GetMarkedRecordsTableIndex(list_object) of form syListObj;
get first table(ListTableReference) by number ListTableIndex;

while err() = OKAY do
	{Attempt to update the contact date for the selected Customer}
	'Customer Number' of table IG_Contact_History_MSTR = 'Customer Number' of table(ListTableReference);
	change table IG_Contact_History_MSTR;

	if err() = OKAY then
		{Item could be locked, so update it}
		'Last Contact Date' of table IG_Contact_History_MSTR = sysdate();
		save table IG_Contact_History_MSTR;
		if err() = OKAY then
			increment SuccessCount;
		else
			increment FailureCount;

			{Log the details of the error}
			UserDefData:'User Defined Text01' = 'Customer Number' of table(ListTableReference);
			UserDefData:'User Defined LongInt01' = IG_PROD_ID;
			ErrorStatus = ActionStatus_LogError(list_object:ActionStatusID,
				list_object:'Error Sequence Number',
				"Customer contact date could not be updated.",
				err(),
				'Customer Number' of table(ListTableReference),
				UserDefData) of form syListObj;

			increment list_object:'Error Sequence Number';
		end if;
	else
		{Item could not be found}
		increment FailureCount;

		{Log the details of the error}
		UserDefData:'User Defined Text01' = 'Customer Number' of table(ListTableReference);
		UserDefData:'User Defined LongInt01' = IG_PROD_ID;
		ErrorStatus = ActionStatus_LogError(list_object:ActionStatusID,
			list_object:'Error Sequence Number',
			"Customer could not be found or has not had initial contact information defined.",
			err(),
			'Customer Number' of table(ListTableReference),
			UserDefData) of form syListObj;

		increment list_object:'Error Sequence Number';
	end if;

	{Get the next Cusotmer to update}
	get next table(ListTableReference) by number ListTableIndex;
end while;

{Log the success and failure results}
ErrorStatus = ActionStatus_LogActionComplete(list_object:ActionStatusID, SuccessCount, FailureCount) of form syListObj;

{Indicate that the mutli-select list action is complete}
call List_MultiSelectActionCompleteEvent of form syListObj, list_object;

If you want to display a different message in the message bar for the list, you can add the GetSummaryStatusMsgText procedure. This procedure is also defined for several core lists in Microsoft Dynamics GP. To display a different message for the message bar for core lists, you would create a procedure trigger that runs after the GetSummaryStatusMsgText procedure. The GetSummaryStatusMsgText procedure has the following parameters:

in syListActionStatusHdrState HdrState;
out string sMsgText;

Use the GetActionID() function of the syListActionStatusObj form, passing in the action status header composite, to retrieve the ID of the action that was performed. If it’s your action being processed, set the “out” parameter to the text you want to display in the message bar. The amount of text is limited to 255 characters.


Documentation Feedback