Operation which creates a task in Progression.
Property |
Type |
Value |
Credentials |
Credentials |
Authentication information |
Task |
Task |
Information concerning the task to be created |
Location |
Location |
Localization information during the task creation (mobile) |
Dispatch |
boolean |
Dispatch task? If yes, a HumanResourceRef must be assigned to the task. |
CreateTaskRequest
|
Java, PHP examples
Java
Task task = new Task(); RecordRef typeRef = new RecordRef(); typeRef.setType(RecordType.TASK_TYPE); typeRef.setLabel("SVC"); // Task type code task.setTypeRef(typeRef); RecordRef priorityRef = new RecordRef(); priorityRef.setType(RecordType.TASK_PRIORITY); priorityRef.setLabel("Normal"); // Priority name task.setPriorityRef(priorityRef); task.setSummary("Test"); task.setDescription("This is a test"); // Appointment configuration final GregorianCalendar gregorianCalendar = new GregorianCalendar(); gregorianCalendar.setTime(new Date()); task.setRv(DatatypeFactory.newInstance().newXMLGregorianCalendar(gregorianCalendar)); // Assignment RecordRef hrRef = new RecordRef(); hrRef.setType(RecordType.HUMAN_RESOURCE); hrRef.setLabel("John Doe"); // Human Resource Name task.setHumanResourceRef(hrRef); // Client (may not be available in some configurations) // The client will be created automatically if it does not exist. RecordRef clientRef = new RecordRef(); clientRef.setType(RecordType.CLIENT); clientRef.setLabel("Diffusion"); // Client Name (Unique) task.setClientRef(clientRef); Address clientAddress = new Address(); clientAddress.setAddress("51 allard"); clientAddress.setCity("Saint-alexis des monts"); clientAddress.setProvince("QC"); // ISO code clientAddress.setCountry("CA"); // ISO code clientAddress.setPostalCode("J0K 1V0"); task.setClientAddress(clientAddress); // Location (may not be available in some configurations) // Client must be created to allow the creation of a location. // The location will be created if it doesn’t exist. RecordRef nodeRef = new RecordRef(); nodeRef.setType(RecordType.NODE); nodeRef.setLabel("Diffusion Granby"); // Location Name (Unique) task.setNodeRef(nodeRef); Address nodeAddress = new Address(); nodeAddress.setAddress("10-4 Place du lac"); nodeAddress.setCity("Granby"); nodeAddress.setProvince("QC"); // ISO code nodeAddress.setCountry("CA"); // ISO code nodeAddress.setPostalCode("J2G 4C3"); task.setNodeAddress(nodeAddress); // Customizable Properties (the names of properties depend on the type of task) task.setProperties(new ArrayOfProperty()); Property p = new Property(); p.setName("test.test1"); p.setValue("test1"); task.getProperties().getProperty().add(p); p = new Property(); p.setName("test.test2"); p.setValue("test2"); task.getProperties().getProperty().add(p); // Item List TaskItemList taskItemList = new TaskItemList(); // Create 2 items TaskItem taskItem = new TaskItem(); taskItem.setQuantity(1); taskItem.setLabel("Computer"); taskItem.setPrice(499.99); taskItemList.getTaskItems().getRecord().add(taskItem); taskItem = new TaskItem(); taskItem.setQuantity(2); taskItem.setLabel("Screen"); taskItem.setPrice(199.99); taskItemList.getTaskItems().getRecord().add(taskItem); taskItemList.setSubTotal(899.97); taskItemList.setTotal(899.97); task.setTaskItemList(taskItemList); // Meta Properties task.setMetas(new ArrayOfProperty()); Property meta = new Property(); meta.setName("MyInternalID"); meta.setValue("123456"); task.getMetas().getProperty().add(meta); // Create Task CreateTaskRequest request = new CreateTaskRequest(); request.setCredentials(credentials); // See login operation request.setTasl(task); request.setDispatch(true); RecordRef taskRef = progressionPortType.createTask(request).getTaskRef(); Long taskId = taskRef.getId(); // Returns the internal ID for the task that was just created. |
PHP
$task = new stdClass(); $task->TypeRef->Type = 'TASK_TYPE'; $task->TypeRef->Label = 'SVC'; $task->PriorityRef = new stdClass(); $task->PriorityRef->Type = 'TASK_PRIORITY'; $task->PriorityRef->Label = 'Normal'; $task->Summary = 'Test'; $task->Description = 'This is a test!'; // Assignation $task->HumanResourceRef = new StdClass(); $task->HumanResourceRef->Type = 'HUMAN_RESOURCE'; $task->HumanResourceRef->Label = "Test"; // Human Resource Name // Client (may not be available in some configurations) // The client will be created automatically if it does not exist $clientRef = new StdClass(); $clientRef->Type = 'CLIENT'; $clientRef->Label = "Diffusion"; // Client Name (Unique) $task->ClientRef = $clientRef; $clientAddress = new StdClass(); $clientAddress->Address = "51 allard"; $clientAddress->City = "Saint-alexis des monts"; $clientAddress->Province = "QC"; // ISO code $clientAddress->Country = "CA"; // ISO code $clientAddress->PostalCode = "J0K 1V0"; $task->ClientAddress = $clientAddress; // Location (may not be available in some configurations) // Client must be created to allow the creation of a location. // The location will be created if it doesn’t exist. $nodeRef = new StdClass(); $nodeRef->Type = 'NODE'; $nodeRef->Label = "Diffusion Granby"; // Location Name (Unique) $task->NodeRef = $nodeRef; $nodeAddress = new StdClass(); $nodeAddress->Address = "10-4 Place du lac"; $nodeAddress->City = "Granby"; $nodeAddress->Province = "QC"; // ISO code $nodeAddress->Country = "CA"; // ISO code $nodeAddress->PostalCode = "J2G 4C3"; $task->NodeAddress = $nodeAddress; // Customizable Properties (the names of properties depend on the type of task) $task->Properties = new StdClass(); $task->Properties->Property = array(); $task->Properties->Property[0] = new StdClass(); $task->Properties->Property[0]->Name = 'info1.NO_INVOICE'; $task->Properties->Property[0]->Value = new SoapVar('1234567890', XSD_STRING, 'string', 'http://www.w3.org/2001/XMLSchema'); $task->Properties->Property[1] = new StdClass(); $task->Properties->Property[1]->Name = 'test.test2'; $task->Properties->Property[1]->Value = new SoapVar('test2', XSD_STRING, 'string', 'http://www.w3.org/2001/XMLSchema'); // Item List $taskItemList = new stdClass(); $taskItemList->TaskItems = new stdClass(); $taskItemList->TaskItems->Record = array(); // Create 2 items $taskItem = new StdClass(); $taskItem->Quantity = 1; $taskItem->Label = "Computer"; $taskItem->Price = 499.99; $taskItem->Taxable = true; $taskItemList->TaskItems->Record[0] = new SoapVar($taskItem, SOAP_ENC_OBJECT, 'TaskItem', "http://task.v1.ws.progression.diffusion.cc"); $taskItem = new StdClass(); $taskItem->Quantity = 2; $taskItem->Label = "Screen"; $taskItem->Price = 199.99; $taskItemList->TaskItems->Record[1] = new SoapVar($taskItem, SOAP_ENC_OBJECT, 'TaskItem', "http://task.v1.ws.progression.diffusion.cc"); //The calculation of SubTotal, Total and TaxesAmount must be done manually. $taskItemList->SubTotal = 899.97; $taskItemList->Total = 899.97; $task->TaskItemList = $taskItemList; // Meta Properties $task->Metas = new StdClass(); $task->Metas->Property = array(); $task->Metas->Property[0] = new StdClass(); $task->Metas->Property[0]->Name = 'MyInternalID'; $task->Metas->Property[0]->Value = new SoapVar('123456', XSD_STRING, 'string', 'http://www.w3.org/2001/XMLSchema'); $createTaskRequest = new StdClass(); $createTaskRequest->credentials = $credentials; $createTaskRequest->task = $task; $createTaskRequest->dispatch = false; $response = null; try { $response = $service->CreateTask($createTaskRequest); echo "Task created "; echo $response->taskRef->Id; echo "<br/>"; } catch (Exception $e){ echo "Error during task creation "; echo "<br/>"; } |