web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Finance forum / To display only the mo...
Finance forum

To display only the modified field in SysDatabaseLog from

(0) ShareShare
ReportReport
Posted on by

Hi All,

i have requirement to show only the modified field in "Database log(SysDataBaseLog  form)" History tab. By default, Database log show all the fields in Grid with data in value , previous value field.

My client want to see only the fields that are modified and hide/Remove rest of the fields.

Refer below screen shot: 

7446.0083.Image-1.png

in buildContents form method(SysDataBaseLog form) i am getting the current value, previous value and field id for the modified fields. But am not able to identify the location where all the fields are dynamically fetch and show on the form. 

Please some one help me with this requirement.

Thanks in advance!!!

  • Martin Dráb Profile Picture
    241,635 Most Valuable Professional on at

    I'm not sure what you mean by "where all the fields are dynamically fetch".

    The data is stored in table field SysDatabaseLog.Data, which is parsed in SysDatabaseLog.getDataAsList() called from buildContents(). The values are then added to the List control in buildContents().

  • Community Member Profile Picture
    on at

    Thanks for reply Martin Dráb ,

    my requirement is only display the edited fields like: Currency field in List view.

    Other field are no need to display like: Blocked, BusRelAccount etc..

    Please advise.

    0880.Image-4.png

  • Suggested answer
    nmaenpaa Profile Picture
    101,174 Moderator on at

    You can look at the form code to see how this view is populated. I don't think you can achieve your requirement with extensions, but if you copy the form you can manipulate it freely and definetely fulfill your functional requirement.

  • Verified answer
    Martin Dráb Profile Picture
    241,635 Most Valuable Professional on at

    Yes, I understand your business requirement. I was reacting to your statement "But am not able to identify the location where all the fields are dynamically fetch and show on the form". It wasn't clear what you meant by "where all the fields are dynamically fetch", therefore I told you both where the data comes from and where it's put to the form.

    If your question is answered, please mark the answer as verified. If it's not, please explain what else you need from us.

  • Verified answer
    nmaenpaa Profile Picture
    101,174 Moderator on at

    And actually you might use CoC on the getDataAsList method and replace the List contents with any list you like. So it might be possible to do it with extension after all.

    But this change would impact all places that use the method. You can use Find references on the method to see where it's used.

    And since such modification would possibly break the audit data output, you need to be careful.

  • Community Member Profile Picture
    on at

    Thanks for reply Nikolaos Mäenpää,

    i achieved this requirement in AX2012. But i don't have any idea to achieve the same requirement in D365 in extention.

    I added my logic in BuildHistory method in SysDataBaseLog from.

    Please find below code for your refrence:

    void buildHistory()

    {

       SysDataBaseLog  log; // gp

       List            datalist; // gp

       ListEnumerator  enumerator; // gp

       container       tmp,con; //gp

       int             s = 0;

       DictTable dictTable;

       DictField dictField;

       DatabaseLog       databaseLog;

       fieldId arrFieldId[];

       int idx;

       int k;

       FormListItem item;

       int i, j;

       fieldId fieldId, extFieldId;

       #Properties;

       startLengthyOperation();

       element.lockWindowUpdate(true);

       list.deleteAll();

       imageArr[0] = 0;

       fieldArr[0] = 0;

       if (sysDatabaseLog.Table)

           dictTable = new DictTable(sysDatabaseLog.Table);

       if (dictTable)

       {

           while select LogTable,LogType,LogField from databaseLog

               where databaseLog.LogTable == dictTable.id() &&

                     databaseLog.LogType  == DatabaseLogType::Update

           {

               if (databaseLog.LogField)

               {

                   arrFieldId[databaseLog.LogField] = true;

               }

               else

               {

                   for (i = 1; i<=dictTable.fieldCnt(); i++)

                   {

                       fieldId = dictTable.fieldCnt2Id(i);

                       dictField = new DictField(dictTable.id(), fieldId);

                       for (j=1; j<= dictField.arraySize(); j++)

                       {

                           extFieldId = fieldId2Ext(fieldId, j);

                           arrFieldId[extFieldId] = true;

                       }

                   }

               }

           }

           for (i = dictTable.fieldCnt(); i; i--)

           {

               fieldId = dictTable.fieldCnt2Id(i);

               dictField = new DictField(dictTable.id(), fieldId);

               // Do not display values for Del_CreatedTime and Del_ModifiedTime in the database log as they are deprecated fields and there values are not updated

               if (dictField && (dictField.name() == #PropertyDel_ModifiedTime

                   || dictField.name() == #PropertyDel_CreatedTime))

               {

                   continue;

               }

               for (j=dictField.arraySize(); j; j--)

               {

                   extFieldId = fieldId2Ext(fieldId, j);

                   k++;

                   //BP Deviation Documented

                   item = new FormListItem(fieldId2name(dictTable.id(), extFieldId));

                   if (arrFieldId[extFieldId] || arrFieldId[fieldId])

                       item.image(imagelist.image(#ImageLog));

                   else

                       item.image(imagelist.image(#ImageLogBlank));

                   imageArr[k] = item.image();

                   fieldArr[k] = extFieldId;

                   // added by GP for only display modified field

                   if(s != 1)

                   {

                     select log

                       order by CreatedDateTime, RecId

                       where log.Table             == sysDataBaseLog.Table &&

                       log.RecId   ==  sysDataBaseLog.RecId &&

                       log.LogRecId          == sysDatabaseLog.LogRecId  &&

                       (log.CreatedDateTime   < dbHistory.CreatedDateTime ||

                       (log.CreatedDateTime  == dbHistory.CreatedDateTime &&

                       log.RecId            <= dbHistory.RecId));

                       {

                           datalist = log.getDataAslist(true);

                           enumerator = datalist.getEnumerator();

                           while (enumerator.moveNext())

                           {

                               tmp = enumerator.current();

                               con = conIns(con,1,conPeek(tmp, 1));// = conPeek(tmp, 1);

                           }

                           s = 1;

                       }

                   }

                   if(conFind(con,extFieldId))

                   {

                       idx = list.addItem(item);

                       item = list.getItem(idx);

                       item.data(k);

                       list.setItem(item);

                   }

                   // end

               }

           }

       }

       element.lockWindowUpdate(false);

       endLengthyOperation();

    }

  • Suggested answer
    nmaenpaa Profile Picture
    101,174 Moderator on at

    If you want to do it with extensions in D365FO your code above is not possible. Instead you need to use CoC on the table method that is called from the form, and replace the standard return list object with your own list.

    But you can always duplicate the whole database log form and implement this buildHistory method there. That's the quickest and easiest solution since you already have code for it.

    Would that resolve your business requirement?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Finance

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans