Use IConfService to query object by Attributes

500 views Asked by At

How do I query objects by attribute (instead of 'Filter Keys') using the Genesys Platform SDK?

Endpoint endpoint = new Endpoint("DEV", "the host", 12020);

endpoint.ServicePrincipalName = "the host/the principle";

_confServerProtocol = new ConfServerProtocol(endpoint);
_confServerProtocol.ClientApplicationType = (int)CfgAppType.CFGSCE;
_confServerProtocol.ClientName = "default";
_confServerProtocol.UserName = "the userid";
_confServerProtocol.Open();

IConfService confService = ConfServiceFactory.CreateConfService(_confServerProtocol);

CfgPersonQuery query = new CfgPersonQuery();

// Need to filter based on an Attribute Value (specifically externalID)

var foo = confService.RetrieveMultipleObjects<CfgPerson>(query);
2

There are 2 answers

0
Eric Scherrer On BEST ANSWER

This worked for me:

CfgXPathBasedQuery query = new CfgXPathBasedQuery(confService, CfgObjectType.CFGPerson, "CfgPerson[@externalID='the value']");
0
M Ram On

Use below:

Uri uri = new Uri("tcp://Host:Port");
Endpoint endpoint = new Endpoint(Guid.NewGuid().ToString(), uri);            
ConfServerProtocol confProtocol = new ConfServerProtocol(endpoint);
confProtocol.ClientApplicationType = (int)CfgAppType.CFGSCE;
confProtocol.ClientName = "default";
confProtocol.UserName = "xxxxxx";
confProtocol.UserPassword = "xxxxxx";

//Channel Open
confProtocol.Open();
IConfService confService = ConfServiceFactory.CreateConfService(confProtocol);

CfgPersonQuery query = new CfgPersonQuery();
query.UserName = "AgentID";
CfgPerson person = confService.RetrieveObjects<CfgPerson>(query);
string ExtID = person.ExternalId;

Note: In this way, Filtering is not possible through ExternalId.