Again, i need some assistence. Now i want to create a ticketstate, but it does not work.
I created the state but the code for the ui-creation fails.
irb(main):042:0> Ticket::State.create_or_update(
irb(main):043:1* name: 'warten auf Kunde',
irb(main):044:1* state_type: Ticket::StateType.find_by(name: 'open'),
irb(main):045:1* created_by_id: 1,
irb(main):046:1* updated_by_id: 1,
irb(main):047:1* ignore_escalation: true,
irb(main):048:1* )
=> #<Ticket::State id: 8, state_type_id: 2, name: "warten auf Kunde", next_state_id: nil, ignore_escalation: true, default_create: false, default_follow_up: false, note: nil, active: true, updated_by_id: 1, created_by_id: 1, created_at: "2019-09-16 10:43:42", updated_at: "2019-09-16 10:43:42">
irb(main):049:0>
irb(main):050:0>
irb(main):051:0> attribute = ObjectManager::Attribute.get(
)
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_new).pluck(:id)
attribute.screens[:edit]['ticket.customer'][:filter] = Ticket::State.by_category(:viewable_customer_edit).pluck(:id)
attribute.save!irb(main):052:1* object: 'Ticket',
irb(main):053:1* name: '8',
irb(main):054:1* )
=> nil
irb(main):055:0> attribute.data_option[:filter] = Ticket::State.by_category(:viewable).pluck(:id)
Traceback (most recent call last):
1: from (irb):55
NoMethodError (undefined method `data_option' for nil:NilClass)
irb(main):056:0> attribute.screens[:create_middle]['ticket.agent'][:filter] = Ticket::State.by_category(:viewable_agent_new).pluck(:id)
Traceback (most recent call last):
1: from (irb):56
NoMethodError (undefined method `screens' for nil:NilClass)
irb(main):057:0> attribute.screens[:create_middle]['ticket.customer'][:filter] = Ticket::State.by_category(:viewable_customer_new).pluck(:id)
Traceback (most recent call last):
1: from (irb):57
NoMethodError (undefined method `screens' for nil:NilClass)
irb(main):058:0> attribute.screens[:edit]['ticket.agent'][:filter] = Ticket::State.by_category(:viewable_agent_new).pluck(:id)
Traceback (most recent call last):
1: from (irb):58
NoMethodError (undefined method `screens' for nil:NilClass)
irb(main):059:0> attribute.screens[:edit]['ticket.customer'][:filter] = Ticket::State.by_category(:viewable_customer_edit).pluck(:id)
Traceback (most recent call last):
1: from (irb):59
NoMethodError (undefined method `screens' for nil:NilClass)
irb(main):060:0> attribute.save!
Traceback (most recent call last):
1: from (irb):60
NoMethodError (undefined method `save!' for nil:NilClass)
After adding the state, something terribly went wrong and you seemed to pasted your code twice.
Let’s just ignore there’s a small issue in the documentation text which I just found thanks to double checking, you might want to run this:
attribute = ObjectManager::Attribute.get(
object: 'Ticket',
name: 'warten auf Kunde',
)
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_new).pluck(:id)
attribute.screens[:edit]['ticket.customer'][:filter] = Ticket::State.by_category(:viewable_customer_edit).pluck(:id)
attribute.save!
And should be fine afterwards.
Please do this in a new console to ensure you’re not within strange positions right now.
Mhhh… Did not work:
irb(main):003:0> attribute = ObjectManager::Attribute.get(
object: 'Ticket',
name: 'warten auf Kunde',
irb(main):004:1* object: 'Ticket',
)
irb(main):005:1* name: 'warten auf Kunde',
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)
irb(main):006:1* )
attribute.screens[:edit]['ticket.agent'][:filter] = Ticket::State.by_category(:viewable_agent_new).pluck(:id)
attribute.screens[:edit]['ticket.customer'][:filter] = Ticket::State.by_category(:viewable_customer_edit).pluck(:id)
attribute.save!=> nil
irb(main):007:0> attribute.data_option[:filter] = Ticket::State.by_category(:viewable).pluck(:id)
Traceback (most recent call last):
1: from (irb):7
NoMethodError (undefined method `data_option' for nil:NilClass)
irb(main):008:0> attribute.screens[:create_middle]['ticket.agent'][:filter] = Ticket::State.by_category(:viewable_agent_new).pluck(:id)
Traceback (most recent call last):
1: from (irb):8
NoMethodError (undefined method `screens' for nil:NilClass)
irb(main):009:0> attribute.screens[:create_middle]['ticket.customer'][:filter] = Ticket::State.by_category(:viewable_customer_new).pluck(:id)
Traceback (most recent call last):
1: from (irb):9
NoMethodError (undefined method `screens' for nil:NilClass)
irb(main):010:0> attribute.screens[:edit]['ticket.agent'][:filter] = Ticket::State.by_category(:viewable_agent_new).pluck(:id)
Traceback (most recent call last):
1: from (irb):10
NoMethodError (undefined method `screens' for nil:NilClass)
irb(main):011:0> attribute.screens[:edit]['ticket.customer'][:filter] = Ticket::State.by_category(:viewable_customer_edit).pluck(:id)
Traceback (most recent call last):
1: from (irb):11
NoMethodError (undefined method `screens' for nil:NilClass)
irb(main):012:0> attribute.save!
Traceback (most recent call last):
1: from (irb):12
NoMethodError (undefined method `save!' for nil:NilClass)
My bad, sorry!
We’re wrong with replacing stuff.
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_new).pluck(:id)
attribute.screens[:edit]['ticket.customer'][:filter] = Ticket::State.by_category(:viewable_customer_edit).pluck(:id)
attribute.save!
No worries, you got me with that as well
One question about the new state.
How can i change the ticketstatecolour of the views?
You can’t.
The indicator colors are defined by the state of the ticket:
grey for pending actions
yellowish for new / open tickets
orange/redish for escalated tickets
green for closed tickets
This can’t be changed at the time being.
Ok, then it is a nice feature request
Thanx for your help again
1 Like
system
closed
January 14, 2020, 1:20pm
#10
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.