How can I modify the custom function and include particular fields?

Hi all,

I'm curious if it's possible to customize the following function by incorporating specific fields, such as (First_name, Lastname, Nationality, etc).

/* Added exclusions parameter to avoid script */

Let ( [
~thisField = GetValue ( fieldList ; 1 ) ;
~thisFieldType = FieldType ( Get ( FileName ) ; ~thisField ) ;

~changelog = changelog & ¶ ;

// Parse previous value for this field from the existing Change Log text
// This next step uses special "arrowhead" characters, not less than and greater than, to reduce the likelihood of finding a match within field contents
~prevValueStart = Position ( ~changelog ; "˂" & ~thisField & "˃" ; 1 ; 1 ) ;
~prevValueStart = Case ( ~prevValueStart > 0 ; Position ( ~changelog ; "\" to \"" ; ~prevValueStart ; 1 ) + 6 ) ;
~prevValue = Case ( ~prevValueStart > 0 ; Middle ( ~changelog ; ~prevValueStart ; Position ( ~changelog ; ¶ ; ~prevValueStart ; 1 ) - ~prevValueStart - 1 ) )

] ;
Case ( not IsEmpty ( ~thisField ) ;

	List (	// Record a change for this field value if it's not a calculation field, and it's not in our ignored list

                                      
		Case ( IsEmpty ( FilterValues ( ~thisField ; exclusions ) ) and Right ( LeftWords ( ~thisFieldType ; 1 ) ; 4 ) ≠ "Calc" ;
			Get ( CurrentHostTimestamp ) & ": " & Get ( AccountName ) & " changed ˂" & ~thisField & "˃" & // Wrapping with "arrowhead" characters
			Case ( MiddleWords ( ~thisFieldType ; 2 ; 1 ) ≠ "Container" ; " from " & Quote ( ~prevValue ) & " to " & Quote ( GetField ( ~thisField ) ) )
		) ;

		Excelisys_ChangeLog ( MiddleValues ( fieldList ; 2 ; ValueCount ( fieldList ) ) ; changelog; exclusions )  // Call the custom function again for all remaining fields in the list

                                          & ("-------------------------------------------")


	)
)

)

Hi, @Saeed , as mentioned in another FM community :wink: you'll want to Exclude certain fields, rather than include the ones you want audited. For example the modification time stamp, the changeLog field itself, etc. would normally be added to the global variable ($$) in the startup script to avoid including them. No modification to the custom function(s) will be required.

Also, exact details will depend on whether you're using the older, original version of the audit log, or the newer "Revised" one. The older version has one custom function, the newer one has four.

I provided rather verbose replies as I attempted to learn what you were experiencing. Happy to add clarification or details here if you prefer.

1 Like

I appreciated your assist me …

1 Like