In my previous blogs, I have explained how to authenticate the SharePoint with JITBIT helpdesk system and create helpdesk tickets in JITBIT.
Please follow the below links to authentication and Creating tickets in JITIT helpdesk system
- Authentication
- Create Ticket in JITBIT System
Now, we are going to implement file upload feature while creating ticket from SharePoint to JITBIT system content, like Images, PDF, Documents, Spreadsheets.
Create a Ticket With File Attachments
POST - https://helpdeskurl/helpdesk/api/ticket
It helps to create a ticket with attachment.
- function createTicket() {
-
-
- catID = $('#picktech').val();
- ticketBody = $('#txtbody').val();
- ticketSubject = $('#txtsub').val();
- pId = $('#picktech2').val();
- var form = new FormData();
- form.append("categoryId", catID);
- form.append("body", ticketBody);
- form.append("subject", ticketSubject);
- form.append("priorityId", pId);
- form.append("userId", unameid);
-
- $.each($('#file')[0].files, function(i, file) {
- form.append('file' + i, file);
- });
-
- $.ajax({
- "async": true,
- "crossDomain": true,
- "url": "https://vinodh.jitbit.com/helpdesk/api/ticket",
- "method": "POST",
- "headers": {
- "authorization": auth
- },
- "processData": false,
- "contentType": false,
- "mimeType": "multipart/form-data",
- "data": form,
- success: function(response) {
- swal({
- title: "Awesome!",
- text: "Ticket: " + response + " has been created successfully",
- type: "success"
- });
- $('#picktech').val("");
- $('#txtbody').val("");
- $('#txtsub').val("");
- $('#picktech2').val("");
- $('#file').val("");
- },
- error: function(error) {
-
- swal({
- title: "Oops!",
- text: "Something Went wrong",
- type: "error"
- });
- }
- });
- }
HTML
- <section class="container-fuild">
- <div class="main-area">
- <div class="row">
- <div class="col-lg-4 col-md-12 col-sm-12" style="padding-top: 20px;">
- <div class="form-group row"> <label for="example-text-input" class="col-2 col-form-label">Name</label>
- <div class="col-4"> <input class="form-control" type="text" value="" id="lblname" disabled> </div>
- </div>
- <div class="form-group row"> <label for="example-text-input" class="col-2 col-form-label">Email</label>
- <div class="col-4"> <input class="form-control" type="text" value="" id="lblemail" disabled> </div>
- </div>
- <div class="form-group row"> <label for="example-text-input" class="col-2 col-form-label">Subject</label>
- <div class="col-4"> <input class="form-control" type="text" value="" id="txtsub" required> </div>
- </div>
- <div class="form-group row"> <label for="exampleTextarea" class="col-2 col-form-label">Message</label>
- <div class="col-4"> <textarea class="form-control" id="txtbody" rows="8"></textarea> </div>
- </div>
- <div class="form-group row"> <label for="exampleSelect1" class="col-2 col-form-label">Priority</label>
- <div class="col-4"> <select class="form-control" id="picktech2">
-
- <option value="-1">Low</option>
-
- <option value="0">Medium</option>
-
- <option value="1">High</option>
-
- <option value="2">Critical</option>
-
- </select> </div>
- </div>
- <div class="form-group row"> <label for="exampleSelect1" class="col-2 col-form-label">Category</label>
- <div class="col-4"> <select class="form-control" id="picktech">
-
- <option value="select">Select</option>
-
- </select> </div>
- </div>
- <div class="form-group row"> <label for="exampleSelect1" class="col-2 col-form-label">Upload</label>
- <div class="col-4"> <input type="file" id="file" name="img" multiple> </div>
- </div> <button type="button" class="btn btn-primary" onclick="createTicket()">Create</button> </div>
- </div>
- </div>
- </section>
Let's create a ticket from SharePoint
After filling the form data, also upload the files. Then, click "Create".
So now, the ticket has been created successfully with attachments. Let's navigate to JITBIT helpdesk system.
Finally, you are able to see the ticket with attachment information.
So, the NEW Ticket has been submitted from SharePoint with JITBIT API.