# Import jobs

Every day @ 23:59 we query the WFM API for the Jobs on that day by running this script:
WFM Job Import (opens new window)

The Job list endpoint is: https://api.workflowmax.com/job.api/list
The individual job endpint is: https://api.workflowmax.com/job.api/get

The SQL query to import jobs is:

INSERT INTO `Jobs` (db_id`,`ID`, `Name`, `Description`, `ClientID`, `ClientName`, `ClientOrderNumber`, `State`, `StartDate`, `DueDate`, `ContactID`, `ContactName`, `InternalID`, `ManagerID`, `ManagerName`, `PartnerID`, `PartnerName`) VALUES ('','$job->ID', '$job->Name', '$jobDescription', '$clientID', '$clientName', '$job->ClientOrderNumber', '$job->State','$job->StartDate', '$job->DueDate', '$contactID','$contactName', '$job->InternalID', '$managerID', '$managerName', '$partnerID', '$partnerName')

We also create an array of jobs:

$jobArray[] = array("ID" => "$job->ID", "Name" => "$job->Name", "Client Name" => "$clientName", "Manager" => "$managerName", "Due" => "$due", "Quote" => "$job->ClientOrderNumber","TheStartDate"=> "$job->StartDate","theStatus"=>"$job->State");

And finally, we loop through all the job tasks and import them into our database:

INSERT INTO `JobTasks` (`db_id`,`JobID`, `Name`, `TaskID`, `TaskRateID`, `EstimatedMinutes`, `ActualMinutes`, `Description`,`ClientName`,`AmtTaxExcl`) VALUES ('','$jobID', '$dept', '$taskID', '$taskTaskID', '$estMins', '$actMinutes', '$taskDescription','$clientName','$amtTaxExcl')

This is the cron that triggers the script: Job import cron script (opens new window)