opendns / autotask-php Goto Github PK
View Code? Open in Web Editor NEWA PHP SOAP wrapper for the Autotask Web Service API
License: BSD 3-Clause "New" or "Revised" License
A PHP SOAP wrapper for the Autotask Web Service API
License: BSD 3-Clause "New" or "Revised" License
Hello, I am looking for a way to get the picklist values and names associated.
For instance, i would like to get the Ticket status(s) list with their associated values. i tried using the following:
$ticketFieldArray = new ATWS\AutotaskObjects\ArrayOfPickListValue;
$ticketFieldArray = $client->getFieldInfo('Ticket');
foreach ($ticketFieldArray->GetFieldInfoResult->Field as $ticketFieldInfo)
{
if ($ticketFieldInfo->{"Name"} == "Status")
{
//print_r($ticketFieldInfo);
$val = $ticketFieldInfo->PicklistValues ;
return $val;
}
}
}
But i cant echo each field and its value.
$val = field_info();
print_r($val);
echo $val->Label;
my response for Print_r
ATWS\AutotaskObjects\ArrayOfPickListValue Object ( [PickListValue] => Array ( [0] => ATWS\AutotaskObjects\PickListValue Object ( [IsActive] => 1 [IsDefaultValue] => 1 [IsSystem] => 1 [Label] => New [SortOrder] => 10 [Value] => 1 [parentValue] => [Fields] => [UserDefinedFields] => ) [1] => ATWS\AutotaskObjects\PickListValue Object ( [IsActive] => 1 [IsDefaultValue] => [IsSystem] => 1 [Label] => Complete [SortOrder] => 100 [Value] => 5 [parentValue] => [Fields] => [UserDefinedFields] => ) [2] => ATWS\AutotaskObjects\PickListValue Object ( [IsActive] => 1 [IsDefaultValue] => [IsSystem] => 1 [Label] => Waiting Customer [SortOrder] => 60 [Value] => 7 [parentValue] => [Fields] => [UserDefinedFields] => ) [3] => ATWS\AutotaskObjects\PickListValue Object ( [IsActive] => 1 [IsDefaultValue] => [IsSystem] => [Label] => In Progress [SortOrder] => 30 [Value] => 8 [parentValue] => [Fields] => [UserDefinedFields] => ) [4] => ATWS\AutotaskObjects\PickListValue Object ( [IsActive] => 1 [IsDefaultValue] => [IsSystem] => [Label] => Waiting Materials [SortOrder] => 50 [Value] => 9 [parentValue] => [Fields] => [UserDefinedFields] => ) [5] => ATWS\AutotaskObjects\PickListValue Object ( [IsActive] => 1 [IsDefaultValue] => [IsSystem] => [Label] => Dispatched [SortOrder] => 20 [Value] => 10 [parentValue] => [Fields] => [UserDefinedFields] => ) [6] => ATWS\AutotaskObjects\PickListValue Object ( [IsActive] => 1 [IsDefaultValue] => [IsSystem] => [Label] => Escalate [SortOrder] => 40 [Value] => 11 [parentValue] => [Fields] => [UserDefinedFields] => ) [7] => ATWS\AutotaskObjects\PickListValue Object ( [IsActive] => 1 [IsDefaultValue] => [IsSystem] => [Label] => Waiting Vendor [SortOrder] => 70 [Value] => 12 [parentValue] => [Fields] => [UserDefinedFields] => ) [8] => ATWS\AutotaskObjects\PickListValue Object ( [IsActive] => 1 [IsDefaultValue] => [IsSystem] => [Label] => Waiting Approval [SortOrder] => 15 [Value] => 13 [parentValue] => [Fields] => [UserDefinedFields] => ) [9] => ATWS\AutotaskObjects\PickListValue Object ( [IsActive] => 1 [IsDefaultValue] => [IsSystem] => [Label] => Assigned [SortOrder] => 11 [Value] => 14 [parentValue] => [Fields] => [UserDefinedFields] => ) ) [Fields] => [UserDefinedFields] => )
Any pointers are appreciated.?
Hello,
I do not know if this is the best form to place this question, but if others are having the same problem I know they would be able to locate the answer here. I am having difficulties getting installed products UDF's or any UDF fields for that matter. I was hoping you would be able to assist.
Here is my query to for Installed Products. Which brings back a laundry list of UDF fields (we have a lot of UDFs.)
$installedProductquery = new ATWS\AutotaskObjects\Query('InstalledProduct');
$installedProductField = new ATWS\AutotaskObjects\QueryField('id');
$installedProductField->addExpression('Equals', '29687616');
$installedProductquery->addField($installedProductField);
I see that [UserDefinedField] is an Array, but I do not know how to filter the Array by the name of the UDF in question.I do not know if I am suppose to use the getUDFInfo function or how to go about it.
Here is my output from $installedProductquery
Thank you in advance!
-Devin
Hello,
I am new to PHP, and I usually list things from MySQL database using while statements and echo from a mysqli_fetch_array.
How can I have the returned data from Autotask into an array that I can work with in the same manner.
Thank you.
I need a way to fetch the subscriptions for a particular Configuration Item using this API.
I have fetched the Configuration Item details to which this subscription belongs using "InstalledProduct" but it only returns me the details of the general tab of Configuration Item.
Can anyone let me know how to fetch the subscription details as well. Thanks.
I found that addExpression does not handle encoding and could result in XML errors:
E.g.
$firstnameField->addExpression('Equals', 'Bob & Ray'); // causes error
$firstnameField->addExpression('Equals', htmlspecialchars('Bob & Ray', ENT_XML1)); // OK
$firstnameField->addExpression('Equals', htmlspecialchars('Bob & Ray', ENT_XML1, 'UTF-8')); // Maybe better?
Tricky fix at this point since many users are likely already handling manually, which may result in double-encoded values.
At least should be presented in ReadMe ...
cant pick time entries of completed tickets
Where can I get the user image? I can't find anything in the models. I thought this must be in the model Resource, but not found
Hello Everybody =)
I'm having problems with creating a new product.
I have made already a query of the already created products to make sure im not missing one of the required fields. I changed only the ID of the object?!
The Object $newProduct:
ATWS\AutotaskObjects\Product Object
(
[Active] => 1
[Name] => egino S22222
[ProductAllocationCodeID] => 29682840
[Serialized] =>
[CostAllocationCodeID] => 29682840
[DefaultVendorID] =>
[Description] =>
[ExternalProductID] =>
[Link] =>
[ManufacturerName] => Manufacturer
[ManufacturerProductName] =>
[MSRP] => 0.00
[PeriodType] =>
[ProductCategory] => 5
[SKU] =>
[UnitCost] => 0.00
[UnitPrice] => 0.00
[VendorProductNumber] =>
[Fields] =>
[UserDefinedFields] => ATWS\AutotaskObjects\ArrayOfUserDefinedField Object
(
[UserDefinedField] =>
)
[id] => 0
[DoesNotRequireProcurement] =>
)
My create command:
$client->create($newProduct)
I always get the same response:
ATWS\AutotaskObjects\CreateResponse Object
(
[createResult] => ATWS\AutotaskObjects\ATWSResponse Object
(
[EntityResults] => ATWS\AutotaskObjects\ArrayOfEntity Object
(
[Entity] =>
)
[EntityResultType] => product
[EntityReturnInfoResults] => ATWS\AutotaskObjects\ArrayOfEntityReturnInfo Object
(
[EntityReturnInfo] =>
[Fields] =>
[UserDefinedFields] =>
)
[Errors] => ATWS\AutotaskObjects\ArrayOfATWSError Object
(
[ATWSError] => ATWS\AutotaskObjects\ATWSError Object
(
[Message] => Conversion from type 'Object' to type 'String' is not valid.
)
[Fields] =>
[UserDefinedFields] =>
)
[ReturnCode] => -1
)
)
Am I missing something fundamental here?
Hey,
I am trying to add a service to a contract, although I cannot find figure out how to get a valid serviceID?
Currently I am getting the error message " Value does not exist for the required field ServiceID. ; on record number [1]."
Ideally I want to be able to create a contract followed by a service that is assigned to the contract that was just created. Is this possible?
Any help would be amazing, thanks!
Hey there, still didnt got time to test the bulkUpdate thing... but today evening or tomorrow ill get there.
I just wondered why no bulk Create exists.
I added a function in the Client.php
public function bulkCreate(array $objs)
{
//$createObjs = array();
$createObjs;
foreach ($objs as $obj) {
if (!$createObjs) $createObjs = new AutotaskObjects\CreateParam($obj);
else $createObjs->Entities[] = $obj;
}
return $this->_call('create', array($createObjs));
}
Hey,
I'm very new to using the API and am trying to add charges/expenses to an existing ticket, which I know is possible I'm just unsure how to approach this.
Currently I am creating tickets using the following function, which was not created by me.
` $assignedResourceID = returnEngineerAutotaskID();
$at = new Autotask($GLOBALS['autotask_username'], $GLOBALS['autotask_password']);
$at->connectToAPI();
$nTicket = new Ticket();
$today = date("Y-m-d");
$due_date = strtotime ('+1 week' , strtotime ($today));
$due_date = date ('d/m/Y' , $due_date);
$nTicket->AccountID = $account_id;
$nTicket->DueDateTime = $due_date;
$nTicket->Priority = 3;
$nTicket->Status = 17;
$nTicket->Title = $title;
$nTicket->QueueID = 29763776;
$nTicket->Description = $description;
$nTicket->AssignedResourceID = $assignedResourceID;
$nTicket->AssignedResourceRoleID = 29682834;
$response = $at->client->create($nTicket);
$returncode = print_r($response->createResult->ReturnCode, 1);
$errors = print_r($response->createResult->Errors, 1);
$ticket_number = print_r($response->createResult->EntityResults->Entity->TicketNumber, 1);
if($returncode == 1 && $errors == 0){
$ticket_number = $ticket_number;
}else{
$ticket_number = "RETURN CODE: $returncode.".$errors;
}
return $ticket_number;`
Is there a way to use the ticket number generated to add onto the existing ticket?
Any help or a point in the right direction would be much appreciated.
Regards,
Andy
would be useful to be able to specify ordering for the query
e.g. CreateDate
I can't seem to create a new ticket. I have all of the correct data that is required by AutoTask to create a new ticket. Below are the required AutoTask Fields (both by AutoTask, and my requirements) and their variables:
Account Name ->AccountID,
Ticket Title -> Title,
Ticket Description -> Description
Ticket Type -> TicketType,
Issue Type -> IssueType,
Sub-Issue Type -> SubIssueType,
Status -> Status
Priority -> Priority
Due Date/Time -> DueDateTime (This may be the cause, but I believe I set the correct date format),
Assign To Queue -> QueueID,
Primary Resource -> AssignedResourceID,
Role -> AssignedResourceRoleID,
Work Type -> AllocationCodeID
I also set id = 0
. I call the script using an AJAX call in AngularJS. This is the XML I get by running print($client->__getLastRequest());
after I try to submit the ticket:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://autotask.net/ATWS/v1_5/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<ns1:create>
<ns1:Entities>
<ns1:Entity xsi:type="ns1:Ticket">
<ns1:id>0</ns1:id>
<ns1:AccountID>29683414</ns1:AccountID>
<ns1:AllocationCodeID>29730387</ns1:AllocationCodeID>
<ns1:Description>Hello World</ns1:Description>
<ns1:DueDateTime>2016-2-31T16:17:10</ns1:DueDateTime>
<ns1:IssueType>24</ns1:IssueType>
<ns1:Priority>3</ns1:Priority>
<ns1:QueueID>2</ns1:QueueID>
<ns1:AssignedResourceID>30751984</ns1:AssignedResourceID>
<ns1:AssignedResourceRoleID>29682834</ns1:AssignedResourceRoleID>
<ns1:Status>1</ns1:Status>
<ns1:SubIssueType>217</ns1:SubIssueType>
<ns1:Title>Test Ticket</ns1:Title>
<ns1:TicketType>2</ns1:TicketType>
</ns1:Entity>
</ns1:Entities>
</ns1:create>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
PHP code is below
$jsonData = file_get_contents('php://input');
$data = json_decode($jsonData );
$ticket = new ATWS\AutotaskObjects\Ticket();
$ticket->id = 0;
$ticket->AccountID = $data->accountID;
$ticket->DueDateTime = $data->dueDate;
$ticket->Title = $data->title;
$ticket->Description = $data->desc;
$ticket->Status = $data->status;
$ticket->Priority = $data->priority;
$ticket->TicketType = $data->ticketType;
$ticket->QueueID = $data->workQueue;
$ticket->AssignedResourceID = $data->primary;
$ticket->AssignedResourceRoleID = $data->role;
$ticket->IssueType = $data->issue;
$ticket->SubIssueType = $data->subIssue;
$ticket->AllocationCodeID = $data->work_type;
$authWsdl = 'https://webservices.autotask.net/atservices/1.5/atws.wsdl';
$opts = array('trace' => 1);
$client = new ATWS\Client($authWsdl, $opts);
$zoneInfo = $client->getZoneInfo($username);
$authOpts = array(
'login' => $username,
'password' => $password,
'trace' => 1, // Allows us to debug by getting the XML requests sent
);
$wsdl = str_replace('.asmx', '.wsdl', $zoneInfo->getZoneInfoResult->URL);
$client = new ATWS\Client($wsdl, $authOpts);
$client->create($ticket);
print($client->__getLastRequest());
This isn't so much an issue with your library, but rather a question on how to help lower the time spent accessing the autotask API, as it's very slow. My thought was getting all the data from autotask, using this library to help scrap the API, and store a store the data locally as JSON files. Then doing API checks would be a lot quicker in theory, correct? Then at the end of every month/week/day, run the scripts again, and get the updated info. Would this be a possibility? I've noticed that if one entry gets returned from an API call, it can easily be formatted into JSON using the json_encode()
function in PHP, but multiple entries don't seem to return as nicely. So any idea how I could do that? or any other alternatives to help speed up the data calls?
On two installations I get an Internal Server Error as SOAPFault. Both nginx and Apache2, Windows and Ubuntu.
Any ideas?
2014/09/19 14:40:49 [error] 25696#0: *108402085 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught SoapFault exception: [HTTP] Internal Server Error in /home/web/www/at/src/Client.php:185
Stack trace:
#0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'https://webserv...', 'http://autotask...', 1, 0)
#1 /home/web/www/at/src/Client.php(185): SoapClient->__soapCall('query', Array)
#2 /home/web/www/at/src/Client.php(158): ATWS\Client->_call('query', Array)
#3 /home/web/www/at/test.php(36): ATWS\Client->query(Object(ATWS\AutotaskObjects\Query))
#4 {main}
thrown in /home/web/www/at/src/Client.php on line 185" while reading response header from upstream, client: 82.204.32.194, server: REMOVED, request: "GET /at/test.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "REMOVED"
I'm struggling to get this package to do anything at all. Tried the basic tutorial and I'm getting a bunch of null values in the result. Is there some options inside of AutoTask I have to enable for the client first? I'm desperate for some advice please, here's what I've tried:
<?php
$username = "username@domain";
$password = "password";
$authWsdl = 'https://webservices.autotask.net/atservices/1.5/atws.wsdl";
$opts = array("trace" => 1);
$client = new ATWS\Client($authWsdl, $opts);
$zoneInfo = $client->getZoneInfo($username);
$authOpts = array(
'login' => $username,
'password' => $password,
'trace' => 1, // Allows us to debug by getting the XML requests sent
);
$wsdl = str_replace('.asmx', '.wsdl', $zoneInfo->getZoneInfoResult->URL);
$client = new ATWS\Client($wsdl, $authOpts);
// Instantiate a Query object, designed to make complex
// queries simple.
$query = new ATWS\AutotaskObjects\Query('Contact');
$firstnameField = new ATWS\AutotaskObjects\QueryField('firstname');
$firstnameField->addExpression('Equals', 'John');
$query->addField($firstnameField);
// If you want to debug the XML produced by the Query object
$result.=var_dump($query->asXml());
$result.= " | ";
// Print the results of the query
$result.=var_dump($client->query($query));
$result.= " | ";
$result.="authWsdl: $authWsdl |";
$result.="client: $client |";
$result.="zoneInfo: $zoneInfo |";
"result": " | | authWsdl: https://webservices.autotask.net/atservices/1.5/atws.wsdl |client: |zoneInfo: |"
Hello, first of all, thanks a lot for this client, it really helped me to understand the API AT.
Now here's my issue. For exemple, if i have only the InternalProductID (the id my inc gave it to it) of a product and i need its name and its manufacturerProductName (the id that the manufacturer gave it to it), i just need to make a query in the Product objects.
But i need the InvenritoryLocationID too which is in the InventoryItem Object and this object just contains the ProductId
So my question is do i have to make 2 query, one to get the name/manufacturerProductName/Product ID, then one to get the InventoryItem when i have the Product ID
OR can i make a SQL-join-like in 1 query to get the inventoryLocationId and if i can, how do i do ?
Thanks a lot and sorry if I made any english mistakes, it's not my mother tongue and i have a lot to learn.
So I know there is no expression for a doesNotContain
expression, but I can't find something similar. I'm trying to sort through tickets, and I want to seperate tickets that contain or begin with "Alert". I need a list of non-alert tickets, and a list of alert tickets. Which expression would I use? I can easily us the BeginsWith
or Contains
for getting the alert ticket, but I'm not sure the inverts of those to get the non-alert tickets.
Hi,
I'm using this autotask-php scripts and its work fine but i want to know is there possble way to get every account with the api ?
Kind regards,
David
Hi,
I need to create Account in Autotask by using PHP. Then Users will be able to enter their AutoTask credentials to log into the AutoTask portal and access their HelpDesk page.
Could you help me, how can i achive this?
Thanks & Regards,
Rahul Kumar
Hello All, I know i have been active on this :) and asking too many questions. Promise to show end result (If any).
I am trying to get Installed Products for a specific account. which is fine, except that the results brings returns all the UDF that is not even related to the product or the item. I noticed that Autotask Client Portal (for clients) is also having the same issue.
Is this by design, is it locked by AT.
Here is my query. how do i define that for each item, only return the related UDF.
$id = $_REQUEST['id'];
global $client;
$query = new ATWS\AutotaskObjects\Query('InstalledProduct');
$action = new ATWS\AutotaskObjects\QueryField('AccountID');
$action->addExpression('equals', $id);
$query->addField($action);
$result = $client->query($query);
$final = $result->queryResult->EntityResults->Entity;
return $final;
Thank you.
I have fetched contracts, contacts, resource and tickets from autotask succesfully. Now, I need to fetch the attachment for tickets, I have used the ticket id as parentId for fetching the AttachmentInfo but when I try to fetch the Attachment data using the AttachmentInfo id it gives me error in the response.
Unable to cast object of type 'autotask.web.services.API.Attachment' to type 'autotask.web.services.API.Entity
Can anyone help me in this ?
The API for CreateAttachment (as well as the other attachment calls) seems to be missing in the client.
Is it possible to update just one value of an entity?
Ive got hundreds of installed Products, and now we need to update each InstalledProduct. But just one value.
I cant figure out if it is possible to say:
Update WarrantyExpirationDate => '2017-10-30'
for Installed Priduct id=664
if i make a new InstalledProduct object and just set the required fields and the value i want to get updated i loose all the other setted values which are not required...
Do i realy have to fetch each product and set all given values in a new object which ill use to update?
As i mentioned in an issue last year, its not possible to just query the object and use the response as the "new Object" for updating...
We're building a huge synchronisation with our local system. If its the only choice to "recreate" the full object for updating an existing object, i wonder how much work ill have in... 4-6 month with updateing the synchronisation part cause someone added a userdefinedfield...
Hello,
Anyone was able to have the login process loaded as a session in php?
we have a login page that we need to be able to authenticate against Autotask.
Thank you in advance for any thoughts.
Hey,
I can successfully add a Service to a Contract using the ContractService class, however there seems to be no way to add units/unit to the Service through the API.
Is this possible?
Thanks!
So I need to get all the tickets from multiple accounts. I store all the id's of the accounts I need in a variable called $accountResults
which is an array. I create the query, then have a for loop to add the queryField for each account id, as well as add an OR condition. But it doesn't seem to work. Below you'll find my code, as well as the XML output.
PHP Code:
for($i = 0; $i< count($accountResults); $i++){
$ticket = new ATWS\AutotaskObjects\QueryField('accountid');
$ticket->addExpression('equals', $accountResults[$i]);
$query->addField($ticket);
if($i < count($accountResults)){
$orCondition = new ATWS\AutotaskObjects\QueryCondition('OR');
$query->addCondition($orCondition);
}
}
XML Output:
ATWS\AutotaskObjects\QueryResponse Object
(
[queryResult] => ATWS\AutotaskObjects\ATWSResponse Object
(
[EntityResults] => ATWS\AutotaskObjects\ArrayOfEntity Object
(
[Entity] =>
)
[EntityResultType] => ticket
[EntityReturnInfoResults] => ATWS\AutotaskObjects\ArrayOfEntityReturnInfo Object
(
[EntityReturnInfo] =>
[Fields] =>
[UserDefinedFields] =>
)
[Errors] => ATWS\AutotaskObjects\ArrayOfATWSError Object
(
[ATWSError] =>
[Fields] =>
[UserDefinedFields] =>
)
[ReturnCode] => 1
)
)
Is there an easier way to do this?
So I've stumbled upon this on my quest to get all the phone numbers from clients from autotask for a new internal phone system. So I've included the autoload.php file, I've run the tested code and it does print out all the contacts who's first name is Steve. Now how would I pull just the First name, Last name, and Phone number from all this information? Any help would be great, even just a reference to a resource would be loved.
P.S. Love this little library you made, so simple and easier to get up and running.
I am trying to update with this. Are there any examples? I do not get a response from autotask.
PHP Fatal error: SOAP-ERROR: Parsing Schema: unexpected in sequence in /var/www/xxxxx/autotask/Client.php on line 128
PHP Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing Schema: unexpected in sequence in /var/www/xxxxx/autotask/Client.php:128
Stack trace:
#0 /var/www/xxxx/autotask/Client.php(128): SoapClient->SoapClient('https://webserv...', Array)
#1 /var/www/xxxxx/autotask/verify.php(21): ATWS\Client->__construct('https://webserv...', Array)
#2 {main}
thrown in /var/www/xxxxx/autotask/Client.php on line 128
Within the API Best Practices, it says to "...formulate queries to return only records that have changed since the last query. You can do this for selected entities using the LastModifiedDate or LastActivityDate fields."
As it is not possible to return selective fields when querying, is it possible to obtain the LastModifiedDate or LastActivityDate values by any other means without having to return all the fields in an entity?
Hi,
I'm getting the following error:
PHP Fatal error: Uncaught SoapFault exception: [Client] SOAP-ERROR: Encoding: object has no 'id' property in opendns/autotask-php/src/Client.php:198
I'm sure it's something simple that I'm doing wrong.
I'm trying to update a contact
$contact = new ATWS\AutotaskObjects\Contact();
$contact->AccountID = '12345678';
$contact->Active = '0';
$contact->EmailAddress = '[email protected]';
$contact->FirstName = 'name';
$contact->LastName = 'Surname';
$contact->MogilePhone = '082 123 4567
$authOpts = array(
'login' => $username,
'password' => $password,
'trace' => 1, // Allows us to debug by getting the XML requests sent
);
$wsdl = str_replace('.asmx', '.wsdl', $zoneInfo->getZoneInfoResult->URL);
$client = new ATWS\Client($wsdl, $authOpts);
$result = $client->update($contact);
Thank you for your time
Regards
Tony
I've been trying to update a ticket with this code:
<?php
$query = new ATWS\AutotaskObjects\Query('Ticket');
$ticketNumberField = new ATWS\AutotaskObjects\QueryField('ticketnumber');
$ticketNumberField->addExpression('Equals', $number);
$query->addField($ticketNumberField);
$queryResult = $client->query($query);
$ticket = $queryResult->queryResult->EntityResults->Entity;
$ticket->AccountID = $accountID;
$ticket->Description = $description;
$ticket->Title = $subject;
$ticket->Status = $status;
$ticket->Priority = $priority;
$ticket->QueueID = 6;
$ticket->TicketType = $ticketType;
$ticket->IssueType = $issueType;
$ticket->SubIssueType = $subIssueType;
$ticket->Source = $source;
foreach($ticket as $key => $value) {
if ($value === '' || $value === null) {
unset($ticket->$key);
}
}
/*ticket entity at this point:
{
"AccountID": "30455809",
"ChangeApprovalType": 1,
"CreateDate": "2016-06-13T12:41:51.063",
"CreatorResourceID": 29691633,
"Description": "Test Ticket 3",
"DueDateTime": "2016-06-14T00:00:00",
"FirstResponseDateTime": "2016-06-13T12:41:51.063",
"IssueType": "35",
"LastActivityDate": "2016-06-13T12:41:51.187",
"LastCustomerVisibleActivityDateTime": "2016-06-13T12:42:09.137",
"Priority": 9,
"QueueID": 6,
"Source": "12",
"Status": 18,
"SubIssueType": "332",
"TicketNumber": "T20160613.0399",
"TicketType": "1",
"Title": "Test Ticket 3",
"UserDefinedFields": {
"UserDefinedField": null
},
"id": 776537
}
*/
$updateTicketResult = $client->update($ticket);
$lastRequest = $client->__getLastRequest();
/*last request:
776537304558092016-06-13T12:41:51.06329691633Test Ticket 32016-06-14T00:00:00352016-06-13T12:41:51.187961218332T20160613.0399Test Ticket 32016-06-13T12:41:51.063112016-06-13T12:42:09.137
*/
I can't figure out why my last request doesn't have any xml in it at all. Any ideas?
I've been hunting after this error:
"ATWSError": [
{
"Message": "Object reference not set to an instance of an object."
},
{
"Message": "Error updating entity for record number [1]."
}
]
Hello, really sorry to bug you guys again, but I can't seem to find the relationship between an Account and a Ticket. I thought it was a ParentAccountID = AccountID
, where ParentAccountID
was in the Account object and AccountID
was in the Ticket object. It worked at first, but then I found out that not all Account objects have a ParentAccountID
field. So is there a better link between an Account and it's ticket? Or is there just a more efficient way of getting all the tickets related to an Account without doing another query?
I am trying to extract the various time entries for a ticket. However, nothing is returned, but no errors are returned and the ReturnCode is 1
There are definitely TimeEntries associated with the ticket.
Am I missing something in the code below?
`$authOpts = array(
'login' => $username,
'password' => $password,
'trace' => 1,
);
$wsdl = str_replace('.asmx', '.wsdl', $zoneInfo->getZoneInfoResult->URL);
$client = new ATWS\Client($wsdl, $authOpts);
$query = new ATWS\AutotaskObjects\Query('TimeEntry');
$queryexpression = new ATWS\AutotaskObjects\QueryField('TicketID');
$queryexpression->addExpression('Equals', '7946');
$query->addField($queryexpression);
print_r($query);
$results = $client->query($query);
print_r($results);
$notesArray = $results->queryResult->EntityResults->Entity;
print_r($notesArray);`
If I change the Query to "TicketNote", all the ticket notes for the ticket are shown.
Can anyone please help?
Maybe this is a limitation of the AutoTask API, but is there no way to pull data from multiple entities with one query such as by joining tables? I want to pull invoices complete with customer information and billing items, but I'm guessing I'll have to find a creative way to get all the information within a few calls instead of only one.
Composer creates its own autoloader. Include vendor/autoload.php in your application config file and you will have full access to the autotask-php client.
Below is the XML of my query. As I understand it, it should find all tickets with the accountId=29683423 AND ((status!=5 AND status!=18) OR LastActivityDate > 2016-01-10)
. Essentially, it's supposed to grab all open tickets or any that have been made for this account within the last 30 days. The value that is being checked against LastActivityDate
is dynamic.
<queryxml>
<entity>Ticket</entity>
<query>
<field>accountId
<expression op='equals'>29683423</expression>
</field>
<condition>
<condition>
<field>Status
<expression op='notequal'>5</expression>
</field>
<field>Status
<expression op='notequal'>18</expression>
</field>
</condition>
<condition operator="or">
<field>LastActivityDate
<expression op='greaterthan'>2016-01-10</expression>
</field>
</condition>
</condition>
</query>
</queryxml>
I am having troubles adding content to a UDF when creating (or updating) a ticket.
I've got the process to retreive the data, but am having issues with the code.
Is this supported by the API at this time, do you have any example PHP on how to do this?
By default, the Execution time limit is 30 seconds. I however have some queries that loop, and all that looping adds up. Most of the time it takes longer than 30 seconds, so the query times out. Can I crease the time out value to say, 60?
I'm trying to use the function getFieldInfo, but I don't know what to pass as the parameter ($type). I tried sending the field's name, but then I got an "Uncaught SoapFault exception". Are there any examples?
PS:
The examples under "More Detailed Queries" and "Really Detailed Queries" are using $firstnameField->addExpression('StartsWith', 'S');
but 'StartsWith' doesn't exist, we have to use 'BeginsWith'.
Thank you
Hello again!
I'm encountering a problem that when I enter a phone number into a form and submit it, the query doesn't return anything, no results will be found, as my foreach loop just errors. Although, if I enter just the area code "123", I get all the accounts that have a phone number that contain "123". If I try this format "123-456", I still get results back. I also get results back for the following phone formats; "123-456-7" and "123-456-78". However, if I enter a number that's "123-456-789" or "123-456-7890", I'll get the following error when I do my foreach loop, "Trying to get property of non-object in C:\wamp\www\Autotask\myFile.php on line 39".
Below is the code:
$query = new ATWS\AutotaskObjects\Query('Account');
$phone = new ATWS\AutotaskObjects\QueryField('phone');
$phone->addExpression('contains', $phoneNum);
$query->addField($phone);
$results = $client->query($query);
foreach($results->queryResult->EntityResults->Entity as $account){
echo $account->AccountName."<br>";
}
$phoneNum gets it's value from a $_GET[''] request at the top of the page.
But here's the real kicker, while I can't get results back from "123-456-7890", I get results back from "123-654-9870". It seems to be the only one that works, no other numbers out of my list that I have tried, worked.
I need to be able to search through phone numbers to get account ID's so I can get tickets related to that account ID.
Thanks for your help, again.
Hi,
I am currently using the ContractServiceAdjustment class to update Services with new Units and prices.
Although when I update the unit price and unit cost the Unit Price (List) does not change.
Does anyone know how I can update the Unit Price and Unit Price (List) simultaneously?
Any help would be great, thanks!
I am converting datetimes pulled out of the tickets into my local time (London), using the script below
$TimeZoneNameFrom="EST";
$TimeZoneNameTo="Europe/London";
$DateConverted=date_create($TimeStr, new DateTimeZone($TimeZoneNameFrom))->setTimezone(new DateTimeZone($TimeZoneNameTo))->format("Y-m-d H:i:s");
However, the time returned is one hour ahead of the actual time and what it is displayed within the AutoTask Dashboard. Am I wrong in assuming that the datetime is EST?
What I am also finding strange is that when I write back a due date on a ticket, the datetime displayed via the API is correct, but the datetime displayed within the Dashboard is one hour behind.
I would be grateful for any help...
Hi!
I'm writing a simple PHP code, which will allow me to show some data about particular ticket. I've created a query but I've got no idea how to extract only fields that I want (for example only the field: "Description"). Is there any option to save the query results to an array?
Here is a fragment of my code:
require_once('src\autoload.php');
if (isset($_POST['ticket_number'])):
$username = '[email protected]';
$password = 'MYPASSWORD';
$authWsdl = 'https://webservices.autotask.net/atservices/1.5/atws.wsdl';
$opts = array('trace' => 1);
$client = new ATWS\Client($authWsdl, $opts);
$zoneInfo = $client->getZoneInfo($username);
$authOpts = array
(
'login' => $username,
'password' => $password,
'trace' => 1, // Allows us to debug by getting the XML requests sent
);
$wsdl = str_replace('.asmx', '.wsdl', $zoneInfo->getZoneInfoResult->URL);
$client = new ATWS\Client($wsdl, $authOpts);
$query = new ATWS\AutotaskObjects\Query('Ticket');
$ticketNumberField = new ATWS\AutotaskObjects\QueryField('TicketNumber');
$ticketNumberField->addExpression('Equals', $_POST['ticket_number']);
$query->addField($ticketNumberField);
print_r($client->query($query)); // Here I'm printing the result of the query but it's a one big mess.
So I need to create a form that allows an end user to create a new ticket. I have the form all made with the following fields:
-Title
-Description
-Ticket Type
-Status
-Priority
-Work Queue
-Issue Type
-Sub-Issue Type
-Primary Resource
-And Role
These fields are all marked as required in AutoTask for creating a ticket. There is another field which I have yet to find the value for within this library, Work Type
. Where can I find this and can I get a list of every available option at once, or do I have to manually switch and get the value one at a time?
Is there a way of limiting the number of Entities being returned?
For the most part, when querying results, for example "Ticket", I only need things like the Ticket Number, Title, Description, Status - It seems excessive to have to download the fields, when they are not required...?
Is there a reason the queries are running so slow. it takes about a minute for the results to load.
First, thank you for this tool!
I have performed all the tasks; query, create, update and delete. I feel I have a good understanding on how to use your tool. I was wondering on the query, if you would query by a UDF (user defined field).
Right now, I am have a broad query then filtering those each of the results searching for a particular UDF. Then have to loop through the next board query set and so forth. I feel like there is a more efficient way, I just do not know how to do it.
Thank you in advance!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.