I have 3 tables:
Customer: Fname,Lname
AuditLog: CreatedBy,Time,AuditLogId
CustomerLogs:Fname,Lname,AuditLogID(Type:AuditLog)
I have 2 rules for Customer: (when object is created or modified)
If Customer WAS CHANGED OR Customer IS NEW Then
CREATE Auditog WITH Auditog.time=CURRENT_TIMESTAMP,Auditog.CreatedBy=LoggedInSystemUser.LoginName,Auditog.AuditLogId=MAX Auditog.auditId+1
CREATE CustomerLogs WITH CustomerLogs.Fname=ThisCustomer.Fname,CustomerLogs.Lname=ThisCustomer.Lname,CustomerLogs.AuditLogId=CustomerLogs.AuditLogID.AuditLogId
My AuditLog table gets populated correctly. But the AuditLogID in the CustomerLogs table is empty.
What am i doing wrong? Please help as I am new to awareIM
Audit Records
Are you trying to store the ID of the Auditlog in the CustomerLogs BO?
If so, I would try:
CREATE Auditlog WITH Auditlog.time=CURRENT_TIMESTAMP,Auditlog.CreatedBy=LoggedInSystemUser.LoginName
CREATE CustomerLogs WITH CustomerLogs.Fname=Customer.Fname,CustomerLogs.Lname=Customer.Lname,CustomerLogs.AuditLogId=CustomerLogs.AuditLog.id
If so, I would try:
CREATE Auditlog WITH Auditlog.time=CURRENT_TIMESTAMP,Auditlog.CreatedBy=LoggedInSystemUser.LoginName
CREATE CustomerLogs WITH CustomerLogs.Fname=Customer.Fname,CustomerLogs.Lname=Customer.Lname,CustomerLogs.AuditLogId=CustomerLogs.AuditLog.id
Tom - V8.8 build 3137 - MySql / PostGres
Craig,
Since CustomerLogs.AuditLogID is Type:AuditLog
I think you can just do
CREATE CustomerLogs WITH
CustomerLogs.Fname=Customer.Fname,CustomerLogs.Lname=Customer.Lname,CustomerLogs.AuditLogId=AuditLog
Since AuditLog was just created, it should be in context.
Not sure it matters, but what is the relationship between ustomerLogs and AutidLog?
Since CustomerLogs.AuditLogID is Type:AuditLog
I think you can just do
CREATE CustomerLogs WITH
CustomerLogs.Fname=Customer.Fname,CustomerLogs.Lname=Customer.Lname,CustomerLogs.AuditLogId=AuditLog
Since AuditLog was just created, it should be in context.
Not sure it matters, but what is the relationship between ustomerLogs and AutidLog?
Bob
Oops -- My second line should have been:
CREATE CustomerLogs WITH CustomerLogs.Fname=Customer.Fname,CustomerLogs.Lname=Customer.Lname,CustomerLogs.AuditLogId=CustomerLogs.id
CustomerLogs.id should be in context here since it was just created in the first rule.
CREATE CustomerLogs WITH CustomerLogs.Fname=Customer.Fname,CustomerLogs.Lname=Customer.Lname,CustomerLogs.AuditLogId=CustomerLogs.id
CustomerLogs.id should be in context here since it was just created in the first rule.
Tom - V8.8 build 3137 - MySql / PostGres
Tom,
Thanks for your replies...
i did the following and got it working:
Rule invoked when instance ofcustomer object is created:
If Customer IS NEW
Then
CREATE CustomerLogs WITH CustomerLogs.CustNo=ThisCustomer.CustNo,CustomerLogs.Fname=Customer.Fname,CustomerLogs.Lname=Customer.Lname
CREATE Auditog WITH Auditog.objectModified='Customer',Auditog.reference=ThisCustomer.Fname,Auditog.time=CURRENT_TIMESTAMP,Auditog.userId=LoggedInSystemUser.LoginName,Auditog.auditId=MAX Auditog.auditId+1,Auditog.action='new customer'
Rule when an instance of AuditLog is created:
If Auditog IS NEW Then
FIND CustomerLogs WHERE CustomerLogs.auditId IS UNDEFINED
CustomerLogs.auditId=Auditog.auditId
Thanks for your replies...
i did the following and got it working:
Rule invoked when instance ofcustomer object is created:
If Customer IS NEW
Then
CREATE CustomerLogs WITH CustomerLogs.CustNo=ThisCustomer.CustNo,CustomerLogs.Fname=Customer.Fname,CustomerLogs.Lname=Customer.Lname
CREATE Auditog WITH Auditog.objectModified='Customer',Auditog.reference=ThisCustomer.Fname,Auditog.time=CURRENT_TIMESTAMP,Auditog.userId=LoggedInSystemUser.LoginName,Auditog.auditId=MAX Auditog.auditId+1,Auditog.action='new customer'
Rule when an instance of AuditLog is created:
If Auditog IS NEW Then
FIND CustomerLogs WHERE CustomerLogs.auditId IS UNDEFINED
CustomerLogs.auditId=Auditog.auditId
Very useful improvement in build 1212 descibed at http://www.awareim.com/changelog/Readme1212.txt
Function: GET_CHANGES
Description: If an object was changed returns which attributes have been changed as well as old and new values
Parameters: Object name that has been changed
Example: IF MyObject WAS CHANGED THEN CREATE AuditRecord WITH AuditRecord.Description=GET_CHANGES(MyObject)
Function: GET_CHANGES
Description: If an object was changed returns which attributes have been changed as well as old and new values
Parameters: Object name that has been changed
Example: IF MyObject WAS CHANGED THEN CREATE AuditRecord WITH AuditRecord.Description=GET_CHANGES(MyObject)
Tom - V8.8 build 3137 - MySql / PostGres