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

How to control ZenDesk tickets in Redmine. #12

Open
sh970901 opened this issue Jul 14, 2023 · 0 comments
Open

How to control ZenDesk tickets in Redmine. #12

sh970901 opened this issue Jul 14, 2023 · 0 comments

Comments

@sh970901
Copy link

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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant