how to record in Change Log Entry if using Transferfield ?

julkifli33julkifli33 Member Posts: 911
Hi all.
i am using Cloud BC
i have developed on sync button from company A to company B
both companies i have turned on the Change Log Activities.
but in company B it wont recorded in Change Log Entries.

Scenario :
i created new item in company A
so i want to push this new item from Company A to Company B
in company A it is recorded in change log entries, but not in company B

any idea how do i record this in company B ?

My Code
SyncCompany.reset;
        SyncCompany.Setfilter(SyncCompany."Company Name", '<>%1', CompanyName);
        if SyncCompany.findset then begin
            Repeat
                IF FromItem.Get(ParItemNo) then begin
                    MediaGuid := FromItem.Picture.MEDIAID;

                    ToItem.ChangeCompany(SyncCompany."Company Name");
                    ToItem.Reset;
                    if ToItem.get(ParItemNo) then begin
                        ToItem.TRANSFERFIELDS(FromItem);
                        ToItem.Selected := FALSE;
                        ToItem.MODIFY(true);
                        Commit();
                    end
                    else begin
                        ToItem.TRANSFERFIELDS(FromItem);
                        ToItem.Selected := FALSE;
                        ToItem.INSERT(TRUE);
                    end;
                    FromItem.Modify(true);
                end;
 until SyncCompany.next = 0;

Answers

  • edoderooedoderoo Member Posts: 79
    I think that the log entries of B are recorded in company A. I recently reported that, it is not really clear if this is a bug or a feature. You can probably work around this by running the write process in the company of the new records, so log entries are recorded in that company. The read action will then be done in "the other company". This is any way the best construction, because events and code triggers will also be executed in that company.
    IF User.Loves('Edo') THEN ok() ELSE currReport.genSkip;
  • julkifli33julkifli33 Member Posts: 911
    I checked there are only 2 rows in change log entries company B
    which is Last Date Modified and Last DateTime Modified.

    another method i used (for another table) is delete all, and then re-insert back all..
    this method will show all records in change log entries company B.
    for item table i cant use this method
  • edoderooedoderoo Member Posts: 79
    Another question ... do you get the log entries when you make the changes to the table manualy?
    IF User.Loves('Edo') THEN ok() ELSE currReport.genSkip;
  • julkifli33julkifli33 Member Posts: 911
    if manual, yes.. it will be recorded in change log entries.
  • aripermadiaripermadi Member Posts: 9
    I think this is by design , Triggers and functions will still run in the context of the current company , not in the company that you specified in the CHANGECOMPANY function. It will only transfer data . You may need to consider using API to sync between companies if need to trigger the change log.
Sign In or Register to comment.