📚 SAP Business One SDK Help

ChangeLogsService Object
See Also  Members  Example

Description

You can use the change log to gain an overview of changes in most windows of SAP Business One. Each time you update, for example, tax groups, withholding tax, house banks, freight, credit card, authorizations, sales, purchasing documents, production orders, charts of accounts, or UDOs, you can use the ChangeLogsService service to look up the change logs and show the differences between two change logs.

Source table: OGCL.

Object Model



Remarks

To access the change log in the SAP Business One application, open a window and make changes, if necessary; then (with the window still open) choose Tools --> Change Log....

To display the differences between two change log instances, select the instances and choose the Show Differences button.

Example

Getting Change Log and Showing Differences between 2 Change Log Instances (C#)Copy Code
// This sample shows how to use the change log service 
// We will get the change log of business partner with BP Code "BPID01" 
// We will show the differences between 2 ChangeLog instances 
ChangeLogsService cl = (ChangeLogsService)vCompSvr.GetBusinessService(SAPbobsCOM.ServiceTypes.ChangeLogsService); 
GetChangeLogParams GetChLgParam = (GetChangeLogParams)cl.GetDataInterface(ChangeLogsServiceDataInterfaces.clsGetChangeLogParams); 
ChangeLogsParams ChLgParams; 
 
GetChLgParam.Object = BoChangeLogEnum.clCards; //BusinessPartners 
GetChLgParam.PrimaryKey = "BPID01"; // Card Code 
             
// Get Change Log 
ChLgParams = cl.GetChangeLog(GetChLgParam); 
 
// Show the first 2 changes 
// Change Instance 1 
MessageBox.Show("Instance 1: " + ChLgParams.Item(0).LogInstance + 
    ", Object Code: " + ChLgParams.Item(0).ObjectCode + 
    ", Update Date: " + ChLgParams.Item(0).UpdatedDate + 
    ", User Name: " + ChLgParams.Item(0).UserName); 
 
// Change Instance 2 
MessageBox.Show("Instance 2: " + ChLgParams.Item(1).LogInstance + 
    ", Object Code: " + ChLgParams.Item(1).ObjectCode + 
    ", Update Date: " + ChLgParams.Item(1).UpdatedDate + 
    ", User Name: " + ChLgParams.Item(1).UserName); 
 
// Show the differences between the instances 
 
ShowDifferenceParams param = (ShowDifferenceParams)cl.GetDataInterface(ChangeLogsServiceDataInterfaces.clsShowDifferenceParams); 
 
param.Object = BoChangeLogEnum.clCards; // BusinessPartners 
param.PrimaryKey = "BPID01"; // Card Code 
 
// We will get the differences of these 2 instances 
param.LogInstance = 1; 
param.LogInstance2 = 2; 
             
ChangeLogDifferencesParams retparams = null; 
// Get differences 
retparams = cl.GetChangeLogDifferences(param); 
 
// Show the differences 
for (int i = 0; i < retparams.Count; i++) 

    MessageBox.Show("User Name: " + retparams.Item(i).UserName +  
    ", Date: " + retparams.Item(i).Date +  
    ", Changed Field: " + retparams.Item(i).ChangedField + 
    ", New Value: " + retparams.Item(i).NewValue + 
    ", Old Value: " + retparams.Item(i).OldValue + 
    ", Line Number: " + retparams.Item(i).LineNumber + 
    ", Array Offset: " + retparams.Item(i).ArrayOffset); 
}

See Also