Asset's current status extracted from asset's inspections

I have an asset design for which I would like to update one of it’s link attributes to the status of it’s child inspections. Each asset can have multiple inspections so I’m stuck at how to query all the inspections of the asset then sort and filter to the most recent to use to update the Asset’s status.

At the moment, I have a workflow that runs on completion of the inspection (to update metrics about the inspection) and I can use a relation node to get to the inspection’s parent asset. I just don’t know then how to query all inspections of the parent. Any suggestions.

Hi Chris,

I’m unable to find a way to achieve this within Alloy itself, however, it is possible to accomplish this using the API.

Hopefully, someone from Causeway will response regarding this, but if you’re interested, I can share a Python script that will perform the task you described.

Thinking of another method.

Could you open data explorer on the inspections design.
Add an attribute, the completion date of the inspections
Add an attribute, that you want to use to update the parent
Add an attribute, by navigation to the parent asset, and select a unique value on the asset, that will be used later to update that asset.

Export the results

Using some external tool, group by the unique key of the asset and sort by the completion date. You’ll then be able to use the Alloy import gateway to update the assets with the most recent value from the inspections.

So at the moment, the child inspection has two main attributes that I want to pull across into the parent asset - a “Determination status” attribute and a “Date of Review” attribute. I have added these two as new attributes to parent asset into which the workflow will copy the data.

I have managed to get a workflow to run on completion of the inspection. This finds it’s relevant parent asset and if the parent asset’s “Determination Status” and “Date of Review” attributes are not set, the workflow can fill in the parent asset’s attribute from the child inspection i.e. the inspection that triggered the workflow.

This works when the parent hasn’t been filled in yet i.e. the first inspection however what I now need to do is a date comparison that checks if child inspection “date of response” is more recent than the asset “date of response.” This will avoid instances where old inspections are corrected and that feed the wrong data into the asset.

I’ve tried feeding AQS into a filter node via the API to allow variables to be programmed from other nodes but just keep getting errors.

Hi Chris,

Apologies if I am misunderstanding the request - if your child inspections can be archived, could you change the query to search for the attribute you want via the live child inspection?

This would mean older inspections i.e. ‘archived when status = completed’ won’t be searched and changed via the existing workflow.

Hi Chris,

Great to see you getting some support from the community on this one.

Just trying to fully understand the requirement here. Looking at the request, you would like to set the asset status based on the latest inspection of a certain type. This is something that you could certainly do in computations, but would need to ensure that the sorting/filtering of the inspections could be done reliably.

For example, are all the inspections except the latest one going to be completed with the latest one being Issued? If this is the case using a filter in a workflow would work really well.

I think to get this to work smoothly, you would need to do this as an event based trigger as you have done already and update the asset as required.

Thanks,
Andy

I’ve managed to get something to work, here’s the solution. It’s a bit of a kludgy work-around but for the most part it works.

As I’ve described above, the parent asset has been given two new attributes which I want to keep up to date based on the latest/last inspection. These attributes are:

  • Latest Response Outcome
  • Date of last response

Where I was struggling was to get the right filter and update the parent asset as I didn’t want to update the parent if a historic inspection was corrected (as some of our data is patchy). The solution I found was to add a new Date attribute to the inspection called “Asset Last Response Date” and this attribute is set as hidden in both the form and stencil because it’s only there for the computation purpose.

I’ve summarised the workflow below. This is triggered by the inspection being updated and where needed, gets the parent asset through relations etc.

  1. On editing the inspection, filter through those inspections that are connected to an asset type.
  2. Use a relation to get the parent asset
  3. Edit the inspection and fill in the hidden “Asset Last Response Date” based on the “Date of Last Response” attribute from the parent asset
  4. Use a filter to compare this inspection’s “Date of Response” with the hidden “Asset Last Response Date” (which comes from the parent asset). Where the inspection’s “Date of Response” is equal to or more recent “Asset Last Response Date” pass the inspection forward.
  5. Update the parent with the outcome of this inspection and this inspection’s "Date of Response.