Hello! I'm having trouble testing UpsertRequest.
FakeXrm version 2.4.2. Late bound.
Testing the plugin code:
var entityRef = ((UpsertResponse)service.Execute(new UpsertRequest
{
Target = new Entity("entitynme")
{
KeyAttributes = { ["parententityid"] = parentRef },
["field2"] = 1
}
})).Target;
[...]
var query = new QueryExpression("entityname")
{
TopCount = 1,
NoLock = true,
ColumnSet = new ColumnSet("field1"),
Criteria = { Conditions = { new ConditionExpression("parententityid",
ConditionOperator.Equal, patientRef.Id) } }
};
var records = service.RetrieveMultiple(query).Entities; //here error
Before this, I added metadata for the key to the test
var entityMetadata = new EntityMetadata
{
LogicalName = "entityname",
};
var parentAttribute = new LookupAttributeMetadata
{
SchemaName = "parententityid",
RequiredLevel = new AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.None),
Targets = ["parententityname" ],
DisplayName = new Label("Parent", 1033),
Description = new Label("Parent", 1033)
};
entityMetadata .SetAttributeCollection(new List<AttributeMetadata> { parentAttribute });
entityMetadata .SetFieldValue("_keys", new[]
{
new EntityKeyMetadata
{
KeyAttributes = ["parententityid"]
}
});
Context.InitializeMetadata(entityMetadata);
and create a record
var parent = new Entity("parententityname", Guid.NewGuid()){};
var record = new Entity("entityname", Guid.NewGuid())
{
["parententityid"] = parent.ToEntityReference(),
["f2"] = 3
};
Context.Initialize([parent, record]
then run plugin.
The error occurs on the line service.RetrieveMultiple: System.ServiceModel.FaultException1: 'The attribute parententityid does not exist on this entity.'
Please advise what needs to be corrected. Thank you in advance!
Hello! I'm having trouble testing UpsertRequest. FakeXrm version 2.4.2. Late bound. Testing the plugin code:
Before this, I added metadata for the key to the test
and create a record
then run plugin. The error occurs on the line service.RetrieveMultiple:
System.ServiceModel.FaultException1: 'The attribute parententityid does not exist on this entity.'
Please advise what needs to be corrected. Thank you in advance!