We need to get at a specific Cumulocity Managed Object (MO) from EPL to retrieve specific fragment value. E.g. given a key, we want to retrieve the MO referenced by it so that we can get at the value of some of its fragment.
Is it possible to just retrieve that particular MO directly?
Anyone has an example or guidance.
Error messages / full error message screenshot / log file:
N/A
Question related to a free trial, or to a production (customer) instance?
we can filter any MO by passing query parameter based deviceId or name .
Then from the MO response you can fetch any key and its value.
Here is the sample code to find managed object based on Id and fetch MO parameters from response.
FindManagedObject mo := new FindManagedObject;
mo.reqId := Util.generateReqId();
//Filter managed object based in device id
mo.params.add(“query”, “_id eq “+”'”+deviceId+“'”);
/** Subscribe to FindManagedObjectResponse.SUBSCRIBE_CHANNEL to
* listen for responses.
*/
monitor.subscribe(FindManagedObjectResponse.SUBSCRIBE_CHANNEL);
on all FindManagedObjectResponse(reqId=mo.reqId) as response{
log "mo name : "+response.managedObject.name.toString() at INFO;
log "mo type: "+response.managedObject.type.toString() at INFO;
log "mo params.owner: "+response.managedObject.params[“owner”].toString() at INFO;
log "mo params.site: "+response.managedObject.params[“site”].toString() at INFO;
}
send mo to FindManagedObject.SEND_CHANNEL;
}
}