Editing system configuration settings via sopm

English! place to talk about development, programming and coding
Post Reply
gpanou
Znuny newbie
Posts: 3
Joined: 03 Aug 2018, 10:35
Znuny 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
Administrator
Posts: 3954
Joined: 18 Dec 2007, 12:23
Znuny Version: Znuny and Znuny LTS
Real Name: Roy Kaldung
Company: Znuny
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
Znuny and Znuny LTS running on CentOS / RHEL / Debian / SLES / MySQL / PostgreSQL / Oracle / OpenLDAP / Active Directory / SSO

Use a test system - always.

Do you need professional services? Check out https://www.znuny.com/

Do you want to contribute or want to know where it goes ?
Rahul123
Znuny newbie
Posts: 1
Joined: 03 Feb 2020, 11:45
Znuny 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