Hi to everyone,
We are using OTRS 5s, and we need that when the state of a master ticket is changed, the value of a dynamic field that we have defined, will replicated in the slaves that have that master ticket related.
I added the following code in the file /opt/otrs/Kernel/System/Ticket/Event/MasterSlave.pm:
use Kernel::System::ObjectManager;
local $Kernel::OM = Kernel::System::ObjectManager->new();
my $DynamicFieldValueObject = $Kernel::OM->Get('Kernel::System::DynamicFieldValue');
# perform action on linked tickets
TICKETID:
for my $TicketID (@TicketIDs) {
my $CheckSuccess = $Self->_LoopCheck(
TicketID => $TicketID,
UserID => $Param{UserID},
String => 'MasterTicketAction: TicketDynamicFieldUpdate_Causa',
);
next TICKETID if !$CheckSuccess;
# get Causa dynamic field
my $CausaDynamicField = $ConfigObject->Get('Causa::DynamicField');
# set the value
$DynamicFieldValueObject->ValueSet(
FieldID => 8, #$FieldID,
ObjectID => $TicketID,
Value => [
{ ValueText => $Ticket{ 'DynamicField_' . $CausaDynamicField }, },
],
UserID => $Param{UserID},
);
}
return 1;
}
We did several tests, but we didn´t get the dynamic field was updated.
I would appreciate any help you can give us.
Thank you very much.
Regards,
Ramiro
Dynamicfield Update
Moderator: crythias
-
- Znuny guru
- Posts: 2210
- Joined: 13 Mar 2014, 09:16
- Znuny Version: 6.0.14
- Real Name: Rolf Straub
Re: Dynamicfield Update
Please put code into Code tags.
This is what I usually use in a loop:
and to initialize the objects:
This is what I usually use in a loop:
Code: Select all
my $CurFieldConfig = $DynamicFieldObject->DynamicFieldGet(
ID => $CurFieldID,
Name => 'DynamicField',
);
$Success = $DynamicFieldBackendObject->ValueSet(
DynamicFieldConfig => $CurFieldConfig,
ObjectID => $NewTicketID,
Value => $NewValue,
UserID => $Self->{UserID},
);
Code: Select all
my $DynamicFieldObject = $Kernel::OM->Get('Kernel::System::DynamicField');
my $DynamicFieldBackendObject = $Kernel::OM->Get('Kernel::System::DynamicField::Backend');
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
Re: Dynamicfield Update
I tried the code you sent me but I still cannot get it to work.
We have OTRS version 5s.
The code said:
#Don’t we have to put here the real name of the dynamic field in the Name variable?
And here:
#Shouldn’t we use the following structure, depending on the data type we have defined?
like this:
We have OTRS version 5s.
The code said:
Code: Select all
my $CurFieldConfig = $DynamicFieldObject->DynamicFieldGet(
ID => $CurFieldID,
Name => 'DynamicField',
);
And here:
Code: Select all
$Success = $DynamicFieldBackendObject->ValueSet(
DynamicFieldConfig => $CurFieldConfig,
ObjectID => $NewTicketID,
Value => $NewValue, #
UserID => $Self->{UserID},
);
like this:
Code: Select all
Value => [
{
ValueText => 'Contenido',
},
],
-
- Znuny guru
- Posts: 2210
- Joined: 13 Mar 2014, 09:16
- Znuny Version: 6.0.14
- Real Name: Rolf Straub
Re: Dynamicfield Update
Yes, you should provide the ID or the Name of the dynamic field, see here:
http://doc.otrs.com/doc/api/otrs/5.0/Pe ... ld.pm.html
The value will be matched automatically to value_text (or whatever) depending on the provided config, see here:
http://doc.otrs.com/doc/api/otrs/5.0/Pe ... nd.pm.html
http://doc.otrs.com/doc/api/otrs/5.0/Pe ... ld.pm.html
The value will be matched automatically to value_text (or whatever) depending on the provided config, see here:
http://doc.otrs.com/doc/api/otrs/5.0/Pe ... nd.pm.html
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
Re: Dynamicfield Update
Thank you very much Rolf!!
The information you sent us was very useful.
Now it works well!
Regards,
Ramiro
The information you sent us was very useful.
Now it works well!
Regards,
Ramiro
-
- Znuny guru
- Posts: 2210
- Joined: 13 Mar 2014, 09:16
- Znuny Version: 6.0.14
- Real Name: Rolf Straub
Re: Dynamicfield Update
My pleasure, glad it works
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS