Skip to content

Commit

Permalink
Fixes #395 - Deleted state management section via rails
Browse files Browse the repository at this point in the history
  • Loading branch information
ralf401 committed Nov 27, 2023
1 parent c30d5d3 commit ff8c8b7
Showing 1 changed file with 1 addition and 158 deletions.
159 changes: 1 addition & 158 deletions admin/console/working-on-tickets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ don't fit your desired scheme. Renaming would look like so:

Get ticket state types
----------------------

.. Not removed because it is still referenced in API state creation.
This will show all state types needed for creating new ticket states.

Expand All @@ -125,160 +125,3 @@ This will show all state types needed for creating new ticket states.
Above will return both, the type ID and name - e.g.:
``[[1, "new"], [2, "open"], ...``.


Add new ticket state
--------------------

.. note:: **🤓 Missing States you just created?**

You might want to use ``Ticket::State.pluck(:id, :name)``
to get a listing of all available ticket states.

.. tip:: **🙈 ignoring escalations**

You can use ``ignore_escalation: true,`` to ignore possible SLA
calculations (pending reminder and pending close do this by default).

Non-Pending states
~~~~~~~~~~~~~~~~~~

A state that's not a pending state (e.g. open, closed). Just replace ``'open'``
by whatever you need (like closed).

.. code-block:: ruby
>> Ticket::State.create_or_update(
name: 'Developing',
state_type: Ticket::StateType.find_by(name: 'open'),
created_by_id: 1,
updated_by_id: 1,
)
Pending reminders
~~~~~~~~~~~~~~~~~

A pending reminder state that will send a reminder notification to the agent if
the time has been reached.

.. code-block:: ruby
>> Ticket::State.create_or_update(
name: 'pending customer feedback',
state_type: Ticket::StateType.find_by(name: 'pending reminder'),
ignore_escalation: true,
created_by_id: 1,
updated_by_id: 1,
)
Pending Action
~~~~~~~~~~~~~~

A pending action that will change to another state if "pending till" has been
reached.

.. code-block:: ruby
>> Ticket::State.create_or_update(
name: 'pending and reopen',
state_type: Ticket::StateType.find_by(name: 'pending action'),
ignore_escalation: true,
next_state: Ticket::State.find_by(name: 'open'),
created_by_id: 1,
updated_by_id: 1,
)
(optional) Disable date and time picker (pending till) for pending states
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Starting with Zammad 5.0, :admin-docs:`Core Workflows </system/core-workflows.html>`
automatically handles displaying the "pending till" field for pending states.
Below snippet *is not required* and is only relevant if you don't want to
create a workflow within the UI of Zammad.

Replace ``pending customer feedback`` with the pending state of your choice.

.. code-block:: ruby
>> CoreWorkflow.create_if_not_exists(
name: 'remove pending till on state "pending customer feedback"',
object: 'Ticket',
condition_selected: { 'ticket.state_id'=>{ 'operator' => 'is', 'value' => Ticket::State.find_by(name: 'pending customer feedback').id.to_s } },
perform: { 'ticket.pending_time'=> { 'operator' => 'remove', 'remove' => 'true' } },
created_by_id: 1,
updated_by_id: 1,
)
.. _states_to_ui:

Make new states available to UI
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Before being able to use the new states within the WebApp, you need to run the
following commands to make them available.

.. warning::

Please **do not replace** anything below, state_id is a named attribute which
is correct and shall not be replaced!

.. code-block:: ruby
>> attribute = ObjectManager::Attribute.get(
object: 'Ticket',
name: 'state_id',
)
>> attribute.data_option[:filter] = Ticket::State.by_category(:viewable).pluck(:id)
>> attribute.screens[:create_middle]['ticket.agent'][:filter] = Ticket::State.by_category(:viewable_agent_new).pluck(:id)
>> attribute.screens[:create_middle]['ticket.customer'][:filter] = Ticket::State.by_category(:viewable_customer_new).pluck(:id)
>> attribute.screens[:edit]['ticket.agent'][:filter] = Ticket::State.by_category(:viewable_agent_edit).pluck(:id)
>> attribute.screens[:edit]['ticket.customer'][:filter] = Ticket::State.by_category(:viewable_customer_edit).pluck(:id)
>> attribute.save!
Limit available states for customers
------------------------------------

.. tip::

:admin-docs:`Core Workflows </system/core-workflows.html>` allows you to
achieve below described behavior any time without any issues. No need to use
the console if you don't want to!

By default Zammad allows customers to change Ticket states to ``open`` and
``closed``. If this does not meet your requirenments, you can adjust this at
anytime. The below example shows how to restrict your customer to only close
tickets if needed:

.. code-block:: ruby
>> attribute = ObjectManager::Attribute.get(
object: 'Ticket',
name: 'state_id',
)
>> attribute.screens['edit']['ticket.customer']['filter'] = Ticket::State.where(name: ['closed']).pluck(:id)
>> attribute.save!
.. hint::

If you want to allow several different states for customers, you need to
provide the state names as array - like so:
``['closed', 'open', 'my-amazing-state']`` (instead of ``['closed']``).

You can check the current active states that customers can set like so:

.. code-block:: ruby
>> ObjectManager::Attribute.get(
object: 'Ticket',
name: 'state_id',
).screens['edit']['ticket.customer']['filter']
The above will return one or more IDs - if you're not sure which state they
belong to, you can check the state name with the following command.
(Ensure to replace ``{ID}`` with your returned ID(s))

.. code-block:: ruby
>> Ticket::State.find({ID}).name

0 comments on commit ff8c8b7

Please sign in to comment.