user3032348
user3032348

Reputation: 67

Retrieve single entity

I need to extract a single value from entity. It is sort of a global setting and it doesn't have relationships with a calling entity. But when I try to do it with RetrieveMultiple I get an empty response.

string name="objectToRetrieve";
QueryExpression qe = new QueryExpression  { EntityName = "new_setting", ColumnSet =new ColumnSet  ("new_name","new_value")};
qe.Criteria.AddCondition("new_name", ConditionOperator.Equal, name);
EntityCollection response = service.RetrieveMultiple(qe);

When I retrieve it by Guid everything works fine.

Entity response = service.Retreve("new_setting", Guid.Parse("09BF9644-9BBA-E511-80FA-005056924035), new ColumnSet("new_value"));

How do I get it without Guid?

Upvotes: 0

Views: 1021

Answers (1)

Daryl
Daryl

Reputation: 18895

Your retrieve multiple is setup correctly. So there are a couple options that could be happening...

  • if you're getting no records back from the retrieve multiple, then your record you're retrieving by GUID doesn't have new_name value that you think it does.
  • If you're getting a record back and it didn't contain a value for new_value, then you may have multiple records with the same new_name value, and you're getting a different record back. Check the GUID to see if it matches what you're expecting.
  • You potentially have a Plugin that is firing on the retrieve multiple, that is modifying the results returned.
  • Potentially you could also be hitting a different org, or maybe using a different user that doesn't have rights to read that entity because if their org. Is this running in a Plugin, or an external process?

Your code is correct, you'll have to think through what assumption you've made that is not true. I'd first make sure that the GUID of the entity being returned matches what you're expecting.

Upvotes: 1

Related Questions