Assets
Retrieve recent asset jobs
/a/Asset_getLastVisited
Return up to five latest-dated jobs in the endpoint’s included statuses that directly or indirectly link to an asset, while refreshing its cached job summary.
When to use this endpoint
Use Asset_getLastVisited to populate an asset’s recent-work history widget.
The endpoint intentionally recalculates from live job relationships rather than trusting the stored job_details cache.
Authentication and permissions
The request must authenticate with signed API-key fields or a logged-in CRM session. The handler performs no additional page or role-permission check.
The lookup and any write use the authenticated tenant; an ID from another tenant cannot be addressed through this call.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Integer string | Yes | Positive server-side asset ID. App IDs are not accepted. Extra list parameters such as length are ignored. |
Example request
$jobs = FM_api('Asset_getLastVisited', [
'id' => '4821',
]);
Example response
[
{
"id": "78142",
"meeting_time_e": "1787653800"
},
{
"id": "77418",
"meeting_time_e": "1784982600"
}
]
Rows are ordered by meeting_time_e descending and limited to five. Both returned values normally remain JSON strings.
Errors and unusual responses
| Response | Condition |
|---|---|
{"error":"not logged in"} | No authenticated tenant context is available. Invalid signed credentials can be rejected by the dispatcher before the handler runs. |
{"error":"missing or invalid parameter: id"} | id is absent or does not convert to a positive integer. This check precedes login enforcement. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Jobs qualify when they directly target the asset or are linked to it through the legacy asset-job link table.
- Only non-deleted jobs whose status is not
0,3,4, or5are included. Despite the endpoint’s presentation as visit history, the query does not require the job time to be in the past. - The initial asset read has no deleted or archived filter. A nonexistent asset also falls through to the job query rather than producing a not-found error; orphaned direct or link-table relationships for that numeric ID can still produce rows.
- The five-row limit is fixed. There is no caller-controlled pagination or search filter.
Side effects
- When the recalculated JSON differs,
job_detailsis updated on the addressed asset. A missing asset makes that update a no-op.
See it in Fieldmotion
CRM1
Open an asset’s recent-work/last-visited widget and filter Network requests for Asset_getLastVisited. The widget shows an error message when the returned list is empty.
CRM2
Open Assets, choose the Visited History action for a row, and filter Network requests for Asset_getLastVisited. CRM2 uses the same fixed five-row response.
Related endpoints
Asset_getretrieves stored asset fields including the encoded cache when requested.Asset_getNextDatelists all incomplete jobs directly assigned to the asset.