protected override void ExecuteWorkflowLogic() { var record1 = ConvertToEntityReference(Record1Id.Get(Context.ExecutionContext)); var record2 = ConvertToEntityReference(Record2Id.Get(Context.ExecutionContext)); var record2Query = new QueryByAttribute(record2.LogicalName) { ColumnSet = new ColumnSet(false) }; record2Query.AddAttributeValue($"{record2.LogicalName}id", record2.Id); var relationship = new Relationship(RelationshipName.Get(Context.ExecutionContext)); var retrieveRequest = new RetrieveRequest() { ColumnSet = new ColumnSet(false), Target = record1, RelatedEntitiesQuery = new RelationshipQueryCollection { { relationship, record2Query } } }; var retrieveResponse = (RetrieveResponse)Context.SystemService.Execute(retrieveRequest); var isRelationshipExists = retrieveResponse.Entity.RelatedEntities[relationship].Entities.Count != 0; RelationshipExists.Set(Context.ExecutionContext, isRelationshipExists); }
protected override void ExecuteWorkflowLogic() { var record1 = ConvertToEntityReference(Record1Id.Get(Context.ExecutionContext)); var record2 = ConvertToEntityReference(Record2Id.Get(Context.ExecutionContext)); Context.UserService.Execute(new AssociateEntitiesRequest() { Moniker1 = record1, Moniker2 = record2, RelationshipName = RelationshipName.Get(Context.ExecutionContext) }); }