Enabling REST to create assets with multivalued customfields

35 views
Skip to first unread message

Fred Gansevles

unread,
Dec 12, 2013, 9:55:23 AM12/12/13
to at-u...@googlegroups.com
Hi,

for a project of ours we need to create assets thru the REST interface
One of the customfields in these assets is a MultiValue and REST always creates a SingleValue
So i've made a patch for the asset REST interface to take Single/Multi-Value into account

This patch is against rt-extension-assettracker-3.0.0 but should also work with rt-extension-assettracker-2.0.0

Note: My first language is not perl, so maybe a developer can rewrite this patch in a more perly-manner :-)

Fred.
---------------------------------------------------------------------------- CUT HERE -----------------------------------------------------
diff -up html/REST/1.0/Forms/asset/default.orig html/REST/1.0/Forms/asset/default
--- html/REST/1.0/Forms/asset/default.orig      2013-12-12 15:37:39.904936906 +0100
+++ html/REST/1.0/Forms/asset/default   2013-12-12 15:36:52.731386000 +0100
@@ -147,7 +147,11 @@ else {
                     delete $data{$k};
                     next;
                 }
-               $v{"CustomField-".$cf->Id()} = delete $data{$k};
+               if ($cf->SingleValue) {
+                   $v{"CustomField-".$cf->Id()} = delete $data{$k};
+               } else {
+                   $v{"CustomField-".$cf->Id()} = vsplit(delete $data{$k});
+               }
             }
             elsif (lc $k eq 'transactiondata') {
                 $transactiondata = delete $data{$k};

Reply all
Reply to author
Forward
0 new messages