0
Answered

How to get job id of existing job in XTRF smart project

WK Automotive 2 years ago in API updated by Łukasz Kaleta (Senior Customer Success Manager) 2 years ago 5

I would like to update the status of existing jobs in XTRF smart projects using the XTRF Home Portal API.

The API call requires a job ID, but I don't where to find this ID.


End point: .../v2/jobs/{jobId}/status


Following the solution of a similar question on stackoverflow, I have defined a view with a list of jobs that require updating. However, there seems to be no column that holds the {jobId} that is required for the API. There is a column called "Internal ID" that contains a 4-digit number (in my case). But when I use that number in the API call, there's an error:

"Invalid Job ID of a Smart Job. Use new form of Job ID for Smart Jobs (e.g. 2QROVSCO3ZG3NM6KAZZBXH5HMI)."

So apparently, there is a new form for the job ID. Is there a specific column for the view that I should use, or is there another way to retrieve this job ID?

The Job ID can be found in the url (after clicking on a job):
https://simplytranslate.s.xtrf.eu/xtrf/faces/projectAssistant/projects/project.seam?assistedProjectId=5GB3QLPO2QROVSCOR55O3WJVU2Y#/project?jobs=DZAGF2QROVSCOVBJPG2UVBCJZ4II

The Job ID here is DZAGF2QROVSCOVBJPG2UVBCJZ4II


Another way is to retrieve the jobs by the API itself, this can be done for a quote, but also for a project:

Endpoint: /v2/quotes/{quoteId}/jobs 
See here https://simplytranslate.s.xtrf.eu/api/doc/users/pages/v2-quotes.html#GET_/v2/quotes/{quoteId}/jobs

Thanks Dennis,


My application can only retrieve information through the API, so your first suggestion cannot be applied here, unfortunately.


Your second suggestion would work. It does seem quite laborious though: I first need to take the project ID (new form) from my view and use that to retrieve a list of jobs for that project via the API. Then I must iterate through this list and read each job's idNumber via another API call and compare that to the job ID in my view until I find the right job.


If the new job ID would be available as a view column (like the new project ID), I could directly target the right job. Hopefully, this can be added in a future version.


Kind regards,

Bastin 

I think I didn't understand you correctly the first time.


You could also create a new virtual column for the Job with this code:

#if($utils.unwrap($this).getJobAssignmentId().isPresent())$utils.unwrap($this).getJobAssignmentId().get()#end


You can add that to your Jobs view.

Would that work for you?

+1

Brilliant! This is exactly what I need. Thanks Dennis


Kind regards,

Bastin