NAME
Kernel::System::Survey – survey lib
DESCRIPTION
All survey functions. E. g. to add survey or and functions.
PUBLIC INTERFACE
new()
create an object
use Kernel::System::ObjectManager;
local $Kernel::OM = Kernel::System::ObjectManager->new();
my $SurveyObject = $Kernel::OM->Get('Kernel::System::Survey');
SurveyAdd()
to add a new survey
my $SurveyID = $SurveyObject->SurveyAdd(
UserID => 1,
Title => 'A Title',
Introduction => 'The introduction of the survey',
Description => 'The internal description of the survey',
NotificationSender => 'quality@example.com',
NotificationSubject => 'Help us with your feedback!',
NotificationBody => 'Dear customer...',
Queues => [2, 5, 9], # (optional) survey is valid for these queues
TicketTypeIDs => [1, 2, 3], # (optional) survey is valid for these ticket types
ServiceIDs => [1, 2, 3], # (optional) survey is valid for these services
CustomerUserConditions => {
'UserFirstname' => [
{
'Negation' => 0,
'RegExpValue' => '^Mi'
},
{
'Negation' => 1,
'RegExpValue' => '^Ka'
}
],
}, # (optional)
);
SurveyGet()
to get all attributes of a survey
my %Survey = $SurveyObject->SurveyGet(
SurveyID => 123,
);
Returns: %Survey = ( "ChangeBy" => 1, "ChangeTime" => "2017-08-30 11:26:41", "ChangeUserFirstname" => "John", "ChangeUserFullname" => "John Doe", "ChangeUserLastname" => "Doe", "ChangeUserLogin" => "john", "CreateBy" => 1, "CreateTime" => "2017-08-30 11:26:41", "CreateUserFirstname" => "John", "CreateUserFullname" => "John Doe", "CreateUserLastname" => "Doe", "CreateUserLogin" => "john", "CustomerUserConditions" => { "UserLogin" => [ { "Negation" => 0, "RegExpValue" => "" } ] }, "CustomerUserConditionsJSON" => "{\"UserLogin\":[{\"RegExpValue\":\"\",\"Negation\":\"0\"}]}", "Description" => "Selenium Descriptioncustomer", "Introduction" => "Selenium Introduction", "NotificationBody" => "Dear Customer,\r\n\r\nThanks for using our service. Help us to improve us and our services.\r\n\r\nPlease give us feedback on how to improve our services:\r\n\r\nhttp://localhost/otrs/external/survey/\<OTRS_PublicSurveyKey>\r\n\r\nThanks for your help!\r\n\r\nYour OTRS-Team", "NotificationSender" => "quality\@example.com", "NotificationSubject" => "Help us with your feedback!", "Queues" => [], "SendConditionsRaw" => "—\nCustomerUserConditions:\n UserLogin:\n – Negation: 0\n RegExpValue: ''\n", "Status" => "New", "SurveyID" => 49, "SurveyNumber" => 10049, "Title" => "Survey title", ):
SurveyUpdate()
to update an existing survey
$SurveyObject->SurveyUpdate(
UserID => 1,
SurveyID => 4,
Title => 'A Title',
Introduction => 'The introduction of the survey',
Description => 'The internal description of the survey',
NotificationSender => 'quality@example.com',
NotificationSubject => 'Help us with your feedback!',
NotificationBody => 'Dear customer...',
Queues => [2, 5, 9], # (optional) survey is valid for these queues
TicketTypeIDs => [1, 2, 3], # (optional) survey is valid for these ticket types
ServiceIDs => [1, 2, 3], # (optional) survey is valid for these services
CustomerUserConditions => {
'UserFirstname' => [
{
'Negation' => 1,
'RegExpValue' => '^Mi'
},
{
'Negation' => 1,
'RegExpValue' => '^Ka'
}
],
}, # (optional)
);
SurveyList()
to get a array list of all survey items
my %SurveyList = $SurveyObject->SurveyList();
Result: %SurveyList = ( 47 => "Survey title", … );
SurveySearch()
search in surveys
my @IDs = $SurveyObject->SurveySearch(
Number => '134', # (optional)
Title => 'some title', # (optional)
Introduction => 'some introduction', # (optional)
Description => 'some description', # (optional)
NotificationSender => 'user@domain', # (optional)
NotificationSubject => 'some notification subject', # (optional)
NotificationBody => 'some notification body', # (optional)
# is searching in Number, Title, Introduction, Description, NotificationSender,
# NotificationSubject and NotificationBody
What => 'some text', # (optional)
Status => 'some status', # (optional)
CreateTimeNewerDate => '2012-01-01 12:00:00',
CreateTimeOlderDate => '2012-01-31 12:00:00',
CreateBy => '123', #UserID
ChangeTimeNewerDate => '2012-01-01 12:00:00',
ChangeTimeOlderDate => '2012-12-31 12:00:00',
ChangeBy => '123', #UserID
OrderBy => [ 'SurveyID', 'Title' ], # (optional)
# default: [ 'SurveyID' ],
# ()SurveyID, Number, Title, Introduction, Description,
# NotificationSender, NotificationSubject, NotificationBody,
# Status, CreateTime, CreateBy, ChangeTime, ChangeBy)
# Additional information for OrderBy:
# The OrderByDirection can be specified for each OrderBy attribute.
# The pairing is made by the array indexes.
OrderByDirection => [ 'Down', 'Up' ], # (optional)
# default: [ 'Down' ]
# (Down | Up)
Limit => 150, # (optional)
UserID => 1,
);
SurveyStatusSet()
to set a new survey status (Valid, Invalid, Master)
$StatusSet = $SurveyObject->SurveyStatusSet(
SurveyID => 123, # required
NewStatus => 'Master', # required
);
SurveyQueueGet()
get a survey_queue relation as an array reference
my $QueuesRef = $SurveyObject->SurveyQueueGet( SurveyID => 3, # required );
SurveyQueueSet()
add a survey_queue relation
my $Result = $SurveyObject->SurveyQueueSet( SurveyID => 3, # required QueueIDs => [1, 7], # required );
PublicSurveyKeyGet()
get all public survey keys as an array reference
my $PublicSurveyKeysRef = $SurveyObject->PublicSurveyKeyGet( SurveyID => 3, # required TicketIDs => [ 1, 2, 3], # optional RequestSendTimeNewerDate => '2024-12-01 00:00:00', # optional RequestSendTimeOlderDate => '2024-12-01 00:00:00', # optional RequestVoteTimeNewerDate => '2024-12-01 00:00:00', # optional RequestVoteTimeOlderDate => '2024-01-01 00:00:00', # optional Limit => 1, # optional );
PublicSurveyGet()
to get all public attributes of a survey
my %PublicSurvey = $SurveyObject->PublicSurveyGet(
PublicSurveyKey => 'Aw5de3Xf5qA', # required
Invalid => 1, # optional to know if one key
# was already used
);
PublicSurveyInvalidSet()
to set a request invalid
$SurveyObject->PublicSurveyInvalidSet(
PublicSurveyKey => 'aVkdE82Dw2qw6erCda', # required
);
ElementExists()
exists an survey-, question-, answer- or request-element
my $ElementExists = $SurveyObject->ElementExists(
ID => 123, # SurveyID, QuestionID, AnswerID, RequestID
Element => 'Survey' # Survey, Question, Answer, Request
);
GetRichTextDocumentComplete()
get some text ready to show as rich-text attachment in-line
my $RichTextDocumentComplete = $SurveyObject->GetRichTextDocumentComplete(
Text => $RichText, # required
);
_BuildSendConditionStrg()
build send condition string with the single items
my %SendConditions = $SurveyObject->_BuildSendConditionStrg(
TicketTypeIDs => [1, 2, 3], # (optional)
ServiceIDs => [1, 2, 3], # (optional)
CustomerUserConditions => {
'UserFirstname' => [
{
'Negation' => 1,
'RegExpValue' => '^Mi'
},
{
'Negation' => 1,
'RegExpValue' => '^Ka'
}
],
}, # (optional)
);
_SendConditionCheckCustomerField()
This function collects some field config information from the customer user map. In OTRS 6, there is a function in the CustomerUser.pm that should be used instead!!!
my %FieldConfig = $SurveyObject->_SendConditionCheckCustomerField(
FieldName => 'UserEmail',
Source => 'CustomerUser', # optional
);
Returns one field config information.
%FieldConfig = (
Label => 'Email',
DatabaseField => 'email',
StorageType => 'var',
);
_SendConditionGetFieldSelections()
Returns the selections for the given field (merged from all sources). In OTRS 6, there is a function in the CustomerUser.pm that should be used instead!!!
my %SelectionsData = $SurveyObject->_SendConditionGetFieldSelections(
FieldName => 'UserEmail',
);
_SurveyWriteAttachment()
write survey attachment
my $Success = $SurveyObject->_SurveyWriteAttachment(
Content => 'someContent',
Filename => 'example.jpg',
ContentType => 'image/jpeg',
SurveyID => 1,
UserID => 1,
AttachmentType => 1,
);
_SurveyDeleteAttachmentAll()
delete all survey attachments
my $Success = $SurveyObject->_SurveyDeleteAttachmentAll(
SurveyID => 1,
UserID => 1,
);
_SurveyDeleteAttachmentAnswer()
delete all survey attachments
my $Success = $SurveyObject->_SurveyDeleteAttachmentAnswer(
SurveyID => 1,
QuestionID => 1,
AnswerID => 1,
);