Skip to content
This repository was archived by the owner on Aug 9, 2023. It is now read-only.
This repository was archived by the owner on Aug 9, 2023. It is now read-only.

How to control ZenDesk tickets in Redmine. #12

Open
@sh970901

Description

@sh970901

Indeed, it is surprising that you can detect changes in a ticket by using ticket.save to retrieve its information.

  1. How to change the custom field value in ZenDesk
def update_ticket_field_value
      ticket_id = params[:ticket_id]
      ticket = zendesk_client.tickets.find(id: ticket_id)
      Rails.logger.info("Ticket found: #{ticket.inspect}")
      if ticket
        issueNumber = params[:issueNumber]
        ticket.custom_fields = [
          { id: 'custom_ticket_number', value: issueNumber }
        ]
        ticket.save
      end
  end
  1. How to change the ticket status in ZenDesk
    ticket status hold, open, close, pending ... ,
def update_ticket_status
    ticket_id = params[:ticket_id]
    ticket = zendesk_client.tickets.find(id: ticket_id)
    if ticket
      status = params[:status]
      if status == 'hold'
        ticket.status = 'hold'
      elsif status == 'open'
        ticket.status = 'open'
      else
        render json: { success: false, message: 'Invalid status value.'}
        return
      end
      ticket.save
      render json: { success: true, message: 'Ticket status updated successfully.' }
    else
      render json: { success: false, message: 'Ticket not found.' }
    end
  end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions