AugForums.com

An Acumatica User Group

  • Free
    • Start Here
    • Rolodex
    • Podcast
    • Blog
    • Forums
  • Paid
    • AugSQL
    • GI Course
    • GI Library
    • Consulting
  • Register
Acumatica Forums

By using this website, you agree to our Terms of Use (click here)

Forums
AUG Forums
Acumatica Generic I...
Generic inquiry wit...
 
Notifications
Clear all

Questions Generic inquiry with information from Audit history(CT301000)

 
Acumatica Generic Inquiries & Pivot Tables
Last Post by Tim Rodman 2 years ago
9 Posts
4 Users
3 Reactions
4,927 Views
RSS
VJW
Posts: 51
 VJW
Topic starter
December 12, 2018 5:51 am
(@vjw)
Trusted Member
Joined: 6 years ago

Hi

I have a scenario where the customer uses Customer contracts(CT301000) and wants to get information about when(date) a contract item have been added or deleted in the Details-tab. As this information is not present in the ContractDetail DAC, I have setup a Audit(CT301000) for the Customer contracts screen including all fields from the tables Contract, ContractDetail and ContractBillingSchedule.

What I would like to achieve is to get the information from the Audit to a generic inquiry where I can later on add more information etc. With the Inspect element feature, I see that the Audit history(CT301000) seems to consist of the DACs AUAuditFilter, AUAuditKeys and AUAuditValues. I have tried to join these tables together, but do not manage. I end up with errors, for example, "InvalidObjectName 'AUAuditFilter'".

Seems like AUAuditKeys can only be joined with the filed CombinedKey. I have tried to use this for the joins, but as mentioned, end up with errors.

Anyone having any idea of how to get the information from Audit history to and inquiry? Maybe I'm using the wrong tables?


8 Replies
Royce Lithgo
Posts: 557
 Royce Lithgo
December 12, 2018 5:00 pm
(@roycelithgo)
Honorable Member
Joined: 6 years ago

Some of those DACs aren't actual tables - the trick unfortunately is going to be to workout which of the audit DACs exist in the database.

AuditFilter is most definitely not a table (any DAC with Filter in the name isn't usually a table) - it's used for specifying criteria on the page. If you can access the database you can see which Audit tables really exist. Otherwise do some test queries looking at the data in each Audit table (or getting an error if it's a non-DB DAC).


Reply
VJW
Posts: 51
 VJW
Topic starter
December 13, 2018 8:22 am
(@vjw)
Trusted Member
Joined: 6 years ago

Thanks for the reply! I investigated a bit more and found out that the columns in Audit history are created dynamically(which is logical as different screens/tables have different fields). So I'll need to check a bit more on which tables might be involved in this specific scenario and see if I somehow manage to get out the information needed. If anyone has some ideas or tips on what tables to look for I would appreciate any help=)


Reply
Royce Lithgo
Posts: 557
 Royce Lithgo
December 13, 2018 5:33 pm
(@roycelithgo)
Honorable Member
Joined: 6 years ago

Audit history is stored in AuditHistory table. Here's a simple query reflecting a change I made to vendor contact and address:

The problem is that all of the changes are recorded in ModifiedFields field, which has the following structure:

RevisionID0x00<Revision Number>0x00<FieldName>0x00<FieldValue>[<FieldName>0x00<FieldValue>]*

In other words, Revision Id and then one or more field name & value pairs. The delimiter used is unicode Null, or 0x00 (UTF-8 hex).

Here's an example string in JSON encoding:

"RevisionID\u00002\u0000Salutation\u0000Joe Blogs\u0000AssignDate\u000011/07/2014 00:34:05"

Decoded this would be: "RevisionID 2 Salutation Joe Blogs AssignDate 11/07/2014 00:34:05" - so you can see Salutation and AssignDate were updated, although I actually only modified Salutation. The system updated AssignDate. 

The problem is, I can't find any way to replace unicode null with a whitespace in GI. On the Audit History page, the code is obviously parsing this string to assign the dynamic columns in the lower table on that page. I cant find the source code for the PX.SM.AUAuditInquire so I can't see how Acumatica are doing this. Find in Files also doesn't match "modifiedfield". Even if this issue can be resolved, you're still left with a string of fieldname value pairs which you'd need to decide what to do with as it's not exactly end user friendly.

Seeing as Report Designer has the same functions as GI, don't think you'd have any luck with that either. 


Reply
Marcia Walker reacted
Marcia Walker
 Marcia Walker
(@mwalker)
Joined: 3 years ago

New Member
Posts: 2
May 30, 2022 6:52 am
Reply toRoyce LithgoRoyce Lithgo

@roycelithgo Thanks, this is very useful to me.  I was wondering what the delimiter is here, and I'm going to try a few things and see if they work.  I don't have access to do customisations, so I can't try what I would like to, but I might attempt a GI using the delimiter.

I would imagine that the PX.SM.AUAuditInquire code is just looping through the "modifiedfield" data to check field names (which you can also get from the PX.SM.AUAuditField table), and then looping through it again to get the data out.  So e.g. if the field that changed is 5th in the list of fields in the PX.SM.AUAuditField table, then you place the matching data under the fifth column.


Reply
Marcia Walker
 Marcia Walker
(@mwalker)
Joined: 3 years ago

New Member
Posts: 2
May 30, 2022 7:41 am
Reply toMarcia WalkerMarcia Walker
Royce Lithgo

OK, no luck, looks like the delimiter is stripped out before displaying the field in the GI, so there is really no way of working with that data in the GI.  Pity!


Reply
Tim Rodman reacted
VJW
Posts: 51
 VJW
Topic starter
December 14, 2018 6:56 am
(@vjw)
Trusted Member
Joined: 6 years ago

Hi

Also, the AuditHistory table doesn't show any information if/when a row has been deleted. This was one main point to be able to show. If that would have been included I think we could have used the somewhat "messy" information in the ModifiedFields-field. Either way, in this case now we will just use the Audit history(SM205530) screen to view the information. Thank you very much for your help and investigation! 🙂 


Reply
Royce Lithgo
Posts: 557
 Royce Lithgo
December 16, 2018 4:27 pm
(@roycelithgo)
Honorable Member
Joined: 6 years ago

When you said "doesn't show any information if/when a row has been deleted" I thought you meant that it doesn't Audit deletes, which it does. But the data from the deleted row isn't recorded in the Audit table, which is what I think you were after. 

You could try adding on to this idea:

https://feedback.acumatica.com/ideas/ACU-I-259

 


Reply
Tim Rodman reacted
Tim Rodman
Posts: 3193
 Tim Rodman
Admin
December 7, 2023 5:29 pm
(@timrodman)
Famed Member
Joined: 10 years ago

Unfortunately, AugSQL (click here) doesn't support MySQL at this time which MYOB runs on, but I was able to do the following in an Acumatica SaaS environment (which runs on Microsoft SQL Server) using AugSQL.

Now, I know that there could be pipes in the data so this isn't perfect, but the following delimits the fields with pipes. You could use something other than pipes or maybe use multiple characters like two pipes together.

I don't understand why I had to use "COLLATE Latin1_General_BIN", but I found that in a Google search somewhere and it seemed to work so I used it.

SELECT TOP 100 ModifiedFields,
REPLACE(ModifiedFields COLLATE Latin1_General_BIN,NCHAR(0) COLLATE Latin1_General_BIN,'|') 'ModifiedFieldsWithPipe'
FROM AuditHistory
WHERE CompanyID=2

 

image

 

I'm using this technique to create a SQL View that is the AuditHistory table, but with the new version of my ModifiedFields column that has pipes for the delimiter. Then I'll be able to work with it in Generic Inquiries.

CREATE VIEW dbo.MyViewsAuditHistoryWithPipes AS
SELECT CompanyID,BatchID,ChangeID,ScreenID,UserID,ChangeDate,
Operation,TableName,CombinedKey,
REPLACE(ModifiedFields COLLATE Latin1_General_BIN,NCHAR(0) COLLATE Latin1_General_BIN,'|') 'ModifiedFields'
FROM AuditHistory

Reply
Forum Jump:
  Previous Topic
Next Topic  
Forum Information
Recent Posts
Unread Posts
Tags
  • 12 Forums
  • 2,526 Topics
  • 10.9 K Posts
  • 36 Online
  • 2,338 Members
Our newest member: Shoaib Shafquat
Latest Post: Pick List report suddenly not splitting on Shipment
Forum Icons: Forum contains no unread posts Forum contains unread posts
Topic Icons: Not Replied Replied Active Hot Sticky Unapproved Solved Private Closed

Online Members

 No online members at the moment

Acumatica Forums

Terms of Use & Disclaimers :: Privacy Policy

Copyright © 2025 · AUG Forums, LLC. All rights reserved. This website is not owned, affiliated with, or endorsed by Acumatica, Inc.

‹›×

    ‹›×