[Bps-public-commit] rt-extension-rest2 branch, transaction-custom-fields, created. 1.07-2-g11576d0

Michel Rodriguez michel at bestpractical.com
Wed Jul 31 08:15:14 EDT 2019


The branch, transaction-custom-fields has been created
        at  11576d064d4fe660ed23d86d19331a52e3860808 (commit)

- Log -----------------------------------------------------------------
commit 5a50b0a64fbc7eb5cc56f7a343db6174a3ecfcb6
Author: michel <michel at bestpractical.com>
Date:   Tue Jul 30 23:48:47 2019 +0200

    Added Transaction Custom Field updates on Correspond and Comment

diff --git a/lib/RT/Extension/REST2/Resource/Message.pm b/lib/RT/Extension/REST2/Resource/Message.pm
index 57c8ef1..d118334 100644
--- a/lib/RT/Extension/REST2/Resource/Message.pm
+++ b/lib/RT/Extension/REST2/Resource/Message.pm
@@ -93,6 +93,18 @@ sub add_message {
             \400, $msg || "Message failed for unknown reason");
     }
 
+    my @transaction_custom_field_list = grep { m{^Object-RT::Transaction--CustomField} } keys %{$args{CustomFields}};
+    if( @transaction_custom_field_list ) {
+        my %transaction_custom_fields = map { $_ => $args{CustomFields}->{$_} }  @transaction_custom_field_list;
+        my( $ret, $msg) = $TransObj->UpdateCustomFields( %transaction_custom_fields);
+        if( ! $ret ) {
+            RT->Logger->error( "cannot update transaction custom fields: $msg");
+            return error_as_json(
+                $self->response,
+                \400, $msg || "Transaction Custom Fields update failed");
+        }
+    }
+
     $self->created_transaction($TransObj);
     $self->response->body(JSON::to_json([$msg], { pretty => 1 }));
 

commit 11576d064d4fe660ed23d86d19331a52e3860808
Author: michel <michel at bestpractical.com>
Date:   Wed Jul 31 14:11:48 2019 +0200

    added doc for custom fields on transaction

diff --git a/lib/RT/Extension/REST2.pm b/lib/RT/Extension/REST2.pm
index c4b61c6..4d729ca 100644
--- a/lib/RT/Extension/REST2.pm
+++ b/lib/RT/Extension/REST2.pm
@@ -311,6 +311,13 @@ Below are some examples using the endpoints above.
         -d '{ "Content": "Testing a correspondence", "ContentType": "text/plain" }'
         'https://myrt.com/REST/2.0/ticket/6/correspond'
 
+    # Correspond a ticket with a transaction custom field
+    curl -X POST -H "Content-Type: application/json" -u 'root:password'
+        -d '{ "Content": "Testing a correspondence", "ContentType": "text/plain",
+              "CustomFields": {"Object-RT::Transaction--CustomField-2": "custom field value"}
+            }'
+        'https://myrt.com/REST/2.0/ticket/6/correspond'
+
     # Comment a ticket
     curl -X POST -H "Content-Type: text/plain" -u 'root:password'
         -d 'Testing a comment'

-----------------------------------------------------------------------


More information about the Bps-public-commit mailing list