Retrieving fragment value of a specific C8Y MO from EPL

Product/components used and version/fix level:

Backend: 10.15.0329

Detailed explanation of the problem:

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?

Production

Hi Eddie,

The EPL apps ship with some samples, the Query for managed objects seems to fit your use case.

The sample in this case uses a query for retrieving multiple managed objects.
If you can not use the query to narrow this down to a single device, the FindManagedObject also seems to support a deviceId parameter in case you want to use a managed object id for this (FindManagedObject).

In case the deviceId does not work, a query like: findManagedObject.params.add("query", "$filter=( id eq '123' )"); should.

Regards,
Tristan

Hi Eddie,

  1. we can filter any MO by passing query parameter based deviceId or name .
  2. 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;
}
}

Thanks,
Poonam Singh

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.