Using the GET_CHANGES function

Contains tips for configurators working with Aware IM
Post Reply
JonP
Posts: 287
Joined: Thu Feb 16, 2017 9:49 pm
Location: United States

Using the GET_CHANGES function

Post by JonP »

I was looking for an elegant (i.e. lazy) solution for recording changes in a "History" log and I noticed the GET_CHANGES function in the user guide. There is very little explanation and no example of the output. So for what it's worth, here is my experience.

The output is generated as HTML and looks like this (brackets used to generalize the example some):

<div>Created instance [instance #] of [BO]
</div>
<div>
<table border="1" >
<th>Attribute</th>
<th>Old value</th>
<th>New value</th>
<tr>
<td>[Attribute]</td>
<td>This should work</td>
<td>This should work now
</td>
</tr>
</table>
</div>

The table reflects all attributes changed in the BO.

I didn't want the instance/BO stuff at the beginning, so after some trial and error, I was able to remove it using:

Code: Select all

[HistoryBO.Attribute]='<div><table '+WORDS_FROM_RIGHT(GET_CHANGES([BO]),WORD_NUMBER(GET_CHANGES([BO]))-5)
I hope that was useful and if you have any suggestions for improvement to my "elegant" solution, please share.

BTW if support sees this, it would be great if you could add a parameter to use the attribute label instead of the attribute name. I realize that this GET_CHANGES function was probably not meant for customers' eyes, but that's the way I want to use it.
v8.1 on Windows 10 / MySQL 5.6 (local), v8.1 on Windows Server 2016 / MySQL 5.6 (server)
tford
Posts: 4238
Joined: Sat Mar 10, 2007 6:44 pm

Re: Using the GET_CHANGES function

Post by tford »

I'm interested in seeing the output of your code.
Tom - V8.8 build 3137 - MySql / PostGres
JonP
Posts: 287
Joined: Thu Feb 16, 2017 9:49 pm
Location: United States

Re: Using the GET_CHANGES function

Post by JonP »

Here's an example:

<div><table border="1" >
<th>Attribute</th>
<th>Old value</th>
<th>New value</th>
<tr>
<td>Name</td>
<td>This should work now</td>
<td>This should work now, really!
</td>
</tr>
</table>
</div>

I think WORDS_FROM_RIGHT doesn't count returns as a break in the word like it does with a space, which makes HTML in particular a little tricky to parse.
v8.1 on Windows 10 / MySQL 5.6 (local), v8.1 on Windows Server 2016 / MySQL 5.6 (server)
rbross
Posts: 441
Joined: Wed Nov 19, 2014 4:13 am
Location: Coventry, Connecticut USA

Re: Using the GET_CHANGES function

Post by rbross »

Jon, I need to use GET_CHANGES for my customer as well. They also need to see the history of what has been changed.
I did something similar but add the fields I needed to see in the History BO and updated them with the values from the record that is in context. it works but could use a little polishing as well.
Roger Ross
AwareIM 8.7 (build 3025) ~ MS-SQL ~ Windows 10 ~
AwareIM 8.5 (build 2828) ~ MS-SQL ~ Windows 10 ~
JonP
Posts: 287
Joined: Thu Feb 16, 2017 9:49 pm
Location: United States

Re: Using the GET_CHANGES function

Post by JonP »

I eventually gave up on GET_CHANGES. It turned out to be too crude for my taste.
v8.1 on Windows 10 / MySQL 5.6 (local), v8.1 on Windows Server 2016 / MySQL 5.6 (server)
rbross
Posts: 441
Joined: Wed Nov 19, 2014 4:13 am
Location: Coventry, Connecticut USA

Re: Using the GET_CHANGES function

Post by rbross »

What was your solution, to call a process when ever a CRUD was done passing the instance in context and creating a history record of the changes for before and after?
Roger Ross
AwareIM 8.7 (build 3025) ~ MS-SQL ~ Windows 10 ~
AwareIM 8.5 (build 2828) ~ MS-SQL ~ Windows 10 ~
JonP
Posts: 287
Joined: Thu Feb 16, 2017 9:49 pm
Location: United States

Re: Using the GET_CHANGES function

Post by JonP »

I wound up creating a BO_nameHistory BO for every BO where I wanted to capture changes as well as comments. That BO_nameHistory BO has the following attributes: Attribute (which is not a reserved word), Author, Value, WhenAuthored and a relationship attribute to the BO in question. I also have an attribute, pm_Read, for highlighting attributes that have not yet been read, but I don't have that wired-up yet. For changes, I would just add rules to each BO for when an attribute WAS CHANGED.

For comments, I have a non-persisting BO called Comment with attributes, Business_Object and Comment. I then have a process for each BO that looks like this:

Code: Select all

ENTER NEW Comment WITH Comment.Business_Object='[BO name]' USING Main
where a rule checks Business_Object against a looooong conditional that creates the instance in each History BO.

There's probably a more elegant way to do it.
v8.1 on Windows 10 / MySQL 5.6 (local), v8.1 on Windows Server 2016 / MySQL 5.6 (server)
Post Reply