通过SOAP访问特定的OTRS动态字段值

时间:2018-12-07 08:55:55

标签: perl soap otrs

如何进一步访问此动态字段值?在使用下面的自卸车后,

print Dumper( $Body->{$ResponseKey} );

结果是:

$VAR1 = {
          'Ticket' => {
                      'Title' => 'TPLUS Service PIC',
                      'DynamicField' => [
                                        {
                                          'Value' => '43312',
                                          'Name' => 'BugID'
                                        },                                       
                                        {
                                          'Value' => '6',
                                          'Name' => 'OTRSMV'
                                        },
                                        {
                                          'Value' => '6.13',
                                          'Name' => 'OTRSPLV'
                                        },
                                        {
                                          'Value' => 'Dev',
                                          'Name' => 'OTRSUse'
                                        },
                                        {
                                          'Value' => '2018-03-02 00:28:00',
                                          'Name' => 'RefDate'
                                        },
                                        {
                                          'Value' => '0',
                                          'Name' => 'RefNumber'
                                        },
                                        {
                                          'Value' => '',
                                          'Name' => 'StartTime'
                                        }
                                      ],
                      'StateType' => 'open',
                      'SLAID' => ''
                }
    };

如何访问DynamicField-> RefDate的单个值?谢谢

1 个答案:

答案 0 :(得分:3)

my $fields = $Body->{$ResponseKey}{Ticket}{DynamicField};

my ($ref_date) =
   map $_->{Value},
      grep $_->{Name} eq 'RefDate',
         @$fields;

my %fields;
$fields{ $_->{Name} } = $fields{ $_->{Value} }
   for @{ $Body->{$ResponseKey}{Ticket}{DynamicField} };

my $ref_date = $fields{RefDate};