Catch user CF Update


#1

I’m trying to create a scrip which is triggered upon a user CF Update. From what I can see in the database the transaction is recorded but it seems as the Scrip doesn’t trigger.

I’ve set Condition: On Transaction

Adding logging shows that the Scrip does trigger when I create a ticket but not on the Transaction which occurs when I modify the user CF.


#2

Below You can find some custom conditions for scripts, there also is condition on CF change.
https://rt-wiki.bestpractical.com/wiki/CustomConditionSnippets


#3

Already looped through all of those, non the less these isn’t triggered upon User CF change, the transaction is only caught if it’s through a ticket.


#4

I do this all the time. On Transaction is the wrong condition. See this example below.

# Check for action on custom field, then check custom field value

# Don't continue with the script unless transaction is on a custom field 
my $txn = $self->TransactionObj;
$RT::Logger->debug( "MyScrip - TransactionType: ". $txn->Type );
return 0 unless $txn->Type eq 'CustomField';

# Get custom field name
my $cf = RT::CustomField->new( $self->CurrentUser );
$cf->Load( $txn->Field );
my $cfName = $cf->Name;

# Print CustomFieldName to /opt/rt4/var/log/rt.log (if debug turned on in RT_SiteConfig)
$RT::Logger->debug( "MyScrip - CustomFieldName: ". $cfName );

# Test that the custom field for the transaction is the one we are interested in 
return 0 unless $cfName eq 'Insert_Custom_FieldName_here';

# Show the Old and New values for the custom field in debug...
$RT::Logger->debug( "MyScrip - TransactionOldValue: ". $txn->OldValue. ", TransactionNewValue: ". $txn->NewValue );


return 0 unless $txn->OldValue eq 'Insert_Old_Value_here';
return 0 unless $txn->NewValue eq 'Insert_New_Value_here';

$RT::Logger->debug( "MyScrip - All conditions passed - returning 1");

return 1;

#5

Cheers I’ll give it a try!