Editing system configuration settings via sopm

English! place to talk about OTRS development, programming and coding
Post Reply
gpanou
OTRS newbie
Posts: 3
Joined: 03 Aug 2018, 10:35
OTRS Version?: 6.0.8
Real Name: George Panou
Company: Algosystems SA

Editing system configuration settings via sopm

Post by gpanou »

Hello,

I am trying to set 2 system configuration fields through installing an opm package.

The fields are:

Ticket::Type,
which is a checkbox and I want it to be enabled

and:
Ticket::Frontend::CustomerTicketMessage###DynamicField
which is an array of dynamic fields displayed in the customer front end, and I need to add an entry like this:
Severity <-> 1 - Enabled

I am using the <CodeInstall Type="post"> tag like this:

Code: Select all

<CodeInstall Type="post">
        <![CDATA[
            $Kernel::OM->Get('Kernel::System::DB')->Do(SQL => "INSERT INTO dynamic_field (internal_field, name, label, field_order, field_type, object_type, config, valid_id, create_by, create_time, change_by, change_time) VALUES (0, \"Severity\", \"Severity\", 11, \"Dropdown\", \"Ticket\", \"--- \nDefaultValue: 4 informational \nLink: '' \nLinkPreview: '' \nPossibleNone: '0' \nPossibleValues: \n  1 emergency: 1 emergency \n  2 critical: 2 critical  \n  3 warning: 3 warning  \n  4 informational: 4 informational \nTranslatableValues: '0'\nTreeView: '0' \n\", 1, 1, current_timestamp, 1, current_timestamp); 
            ");
        ]]>

         <![CDATA[
            $Kernel::OM->Get('Kernel::System::DB')->Do(SQL => "INSERT INTO ticket_type ( name, valid_id, create_by, create_time, change_by, change_time) VALUES ( \"RfC / FYI\", 1, 1, current_timestamp, 1, current_timestamp); 
            ");
        ]]>
         <![CDATA[
            $Kernel::OM->Get('Kernel::System::DB')->Do(SQL => "INSERT INTO ticket_type ( name, valid_id, create_by, create_time, change_by, change_time) VALUES (\"Incident\", 1, 1, current_timestamp, 1, current_timestamp); 
            ");
        ]]>
         <![CDATA[
            $Kernel::OM->Get('Kernel::System::DB')->Do(SQL => "INSERT INTO ticket_type ( name, valid_id, create_by, create_time, change_by, change_time) VALUES (\"Change Request\", 1, 1, current_timestamp, 1, current_timestamp); 
            ");
        ]]>
        

        <![CDATA[

                $Kernel::OM->Get('Kernel::System::SysConfig')->SettingUpdate(
                Valid => 1,
                UserID       => 1,  
                Key => 'Ticket::Frontend::CustomerTicketMessage###DynamicField',
                EffectiveValue => {
                    DefaultColumns => {
                    Severity => "1"
                    }
                }
                );

            $Kernel::OM->Get('Kernel::System::SysConfig')->SettingUpdate(
                Name                  => 'Ticket::Type',
                EffectiveValue        => 1,  
                UserID                => 1,
            );
        ]]>
	</CodeInstall>
The database gets properly populated,
I couldn't find what the exact syntax of these settings should be when using the Perl API.

Thank you,
George

root
Moderator
Posts: 2006
Joined: 18 Dec 2007, 12:23
OTRS Version?: 4/5/6
Real Name: Roy Kaldung
Company: Znuny Inc.
Contact:

Re: Editing system configuration settings via sopm

Post by root »

Hi George,

Here's an example implementation and the usage for it. See it as an example implementation.

The reference for the API can be found at https://doc.otrs.com/doc/api/otrs/6.0/P ... ld.pm.html


- Roy
OTRS 5/6 CentOS / RHEL / Debian / SLES / MySQL / PostgreSQL / Oracle / OpenLDAP / Active Directory / SSO

Do you need professional services for the ((OTRS)) Community Edition? Check out https://www.znuny.com/

Rahul123
OTRS newbie
Posts: 1
Joined: 03 Feb 2020, 11:45
OTRS Version?: OTRS Version (4.0.XX
Real Name: Rahul Agarwal
Company: Tech
Location: Delhi
Contact:

Re: Editing system configuration settings via sopm

Post by Rahul123 »

Hi!
Excellent ! I got useful information here. Thank you!

Post Reply