我在更新OTRS 5中的CustomerUser
时遇到问题。
我正在使用命令行Perl脚本和模块。
这就是我的尝试:
#!/usr/bin/perl
use strict;
use warnings;
use lib '/opt/otrs/Kernel/System/CustomerUser/DB';
use File::Basename;
use FindBin qw($RealBin);
use lib dirname( $RealBin );
use lib dirname( $RealBin ) . '/Kernel/cpan-lib';
use lib dirname( $RealBin ) . '/Custom';
use Kernel::System::ObjectManager;
local $Kernel::OM = Kernel::System::ObjectManager->new();
my $CustomerUserObject = $Kernel::OM->Get( 'Kernel::System::CustomerUser' );
#
# Searching for customers below works fine
#
# my $Name = $CustomerUserObject->CustomerName(
# UserLogin => 'admin',
# );
# my @CustomerIDs = $CustomerUserObject->CustomerIDList(
# SearchTerm => 'somecustomer', # optional
# Valid => 1, # optional
# );
# my @CustomerIDs = $CustomerUserObject->CustomerIDs(
# User => 'some-login',
# );
# my %User = $CustomerUserObject->CustomerUserDataGet(
# User => 'franz',
# );
# Here is the problem
my $test = $CustomerUserObject->CustomerUserUpdate(
#Source => 'CustomerUser', # CustomerUser source config
ID => 'admin', # current user login
UserCustomerID => 'acmecompany',
UserLogin => 'newuser', # new user login
UserFirstname => 'myfirst',
UserLastname => 'mylast',
UserPassword => '', # not required
UserEmail => 'whatever@gmail.com',
ValidID => 1,
UserID => 4,
);
以下是我收到的错误:
DBD :: mysql :: db失败:无法添加或更新子行:外键约束失败(
otrs
。customer_user
,CONSTRAINT
FK_customer_user_change_by_id
外键(change_by
)参考文献
users
(id
))/opt/otrs/Kernel/System/DB.pm第462行。错误:
?LogPrefix?-27 Perl:5.22.1 OS:linux时间:1月19日星期五17:29:12 2018消息:无法添加或更新子行:外键约束
失败(otrs
。customer_user
,CONSTRAINT
FK_customer_user_change_by_id
外键(change_by
)参考文献
users
(id
)),SQL:'UPDATE customer_user SET customer_ids =?,
title =?,first_name = ?, last_name = ?, login = ?, email =?,
customer_id =?,phone = ?, fax = ?, mobile = ?, street = ?, zip
=?,city = ?, country = ?, comments = ?, valid_id = ?, change_time = '2018-01-19 17:29:12' ,change_by =? WHERE LOWER(登录)= LOWER(?)'追溯(19212):模块:
Kernel :: System :: CustomerUser :: DB :: CustomerUserUpdate Line:961
模块:Kernel :: System :: CustomerUser :: CustomerUserUpdate Line:473
模块:update.pl行:30
我已阅读了相关文档
Kernel::System::CustomerUser
,
没有进展。有些文档甚至看起来不正确。
编辑:这是数据库值:
| id | login | email | customer_id | pw | title | first_name | last_name | phone | fax | mobile | street | zip | city | country | comments | valid_id | create_time | create_by | change_time | change_by | customer_ids |
| 4 | admin | whatever@gmail.com | acmecompany | <passwordhash> | Mr. | myfirst | mylast | | | | | | | | | 1 | 2018-01-16 11:30:11 | 1 | 2018-01-19 16:50:18 | 2 | 1 |