Set state for customer to "new" by creation

How can I set the state to “new” (or something else) as default by ticket creation from the customer view via console?

I’am not familiar with ruby so I would appreciate help or tips.

Addition: Is there an attribute like ‘ui_ticket_create_default_type’ but with ‘state’?

Don’t know about the console but it’s easily done with a core workflow. Just create a new workflow like the following:

Hi, thanks for reply. I know that it is possible to handle it through the Coreworkflows and was wondering if there is an other way.
It didn’t work with console commands that I was trying to use. So, let it be.

Sorry, I wasn’t aware that you know about core workflows.
You could use another method with the ruby console: limit the available states for customers in the ticket creation screen to only one. This process is described here.
For the ticket creation screen I would first check which states are available to customers at the moment

ObjectManager::Attribute.get(
     object: 'Ticket',
     name: 'state_id',
   ).screens['create_middle']['ticket.customer']['filter']

This will return a list with IDs. You can check the names belonging to the IDs like this

Ticket::State.all

To limit customers in the ticket creation mask to the state “New” you could enter the following command

attribute = ObjectManager::Attribute.get(
  object: 'Ticket',
  name: 'state_id',
)
attribute.screens['create_middle']['ticket.customer']['filter'] = Ticket::State.where(name: ['new']).pluck(:id)
attribute.save!

All of these command are run on the Ruby console zammad run rails c

2 Likes

I tried that too (via ruby rails) but somehow it didn’t work. I will try it again with your solution/suggestion.

Thanks a lot :heart:

do you know how to set the “new” status for agents to default. For e.g. phone tickets? It is set to “Open” by default, although default_create: is set to “true” for status:new, But I believe this only effects for customers.

Warning Using default_create: true depends on the administrator setting the other default create state to false. Other wise Zammad will not behave as expected. This attribtue affects both agents and customers.

If you need this for customers only, better stick with Core Workflows.

My recommendation is to use core workflows, I use them myself for the same purpose. You can see my example above, just change role to Agent

1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.