Create a new ticket by scripting


 Create a new ticket in scripts - simplest form, no forms or attachments:

var description = "Some description with \nmultiple lines.";
var title = "New job";
var minutes = 60;
var ownerId = 23;
var adressedGroupId = 12;
var newTicketId=helper.createTask(adressedGroupId, title, description, minutes, ownerId, null, null);  

Add a form to the new ticket:
This adds a form #150 to the new ticket.

var description = "Some description with \nmultiple lines.";
var title = "New job";
var minutes = 60;
var ownerId = 23;
var adressedGroupId = 12;
// register the java type of a HashMap in javascript:
var JHashMap = Java.type("java.util.HashMap");
// create the maps:
// a map of forms:
var forms=new JHashMap;
// this ist the form:
var someForm=new JHashMap;

// add field/value pairs to the form:
// make sure to use the right field names and types for your form:
someForm.put("FieldName1", "FieldVal1");
someForm.put("FieldName2", "FieldVal2");
// add the form content to the map of forms,
// use the forms Id as the key:
forms.put(new java.lang.Long(150), someForm);

// create the new ticket:
var newTicketId=helper.createTask(adressedGroupId, title, description, minutes, ownerId, forms, null);  

Create a new ticket with an attachment:

var toGroup = 201;
var owner = 223;
var minutes=60;

// create the attachment list:  
var attachmentList = new java.util.ArrayList();

// create an attachment object of type com.proxemo.todo.bom.ToDoAttachment

var JAttachment = Java.type("com.proxemo.todo4.bom.ToDoAttachment");
var attachment = new JAttachment();

// assign byte content and filename:
// var excelFile = ... // of type byte[]
attachment.setAttachmentContent(excelFile);
attachment.setAttachmentName("Kandidaten.xlsx");
// add the new attachment to the list:  
attachmentList.add(attachment);

// create ticket and pass the attachment list:
ticketId=helper.createTask(toGroup, "Some title", "Some description", minutes, owner, null, attachmentList);