Step 1 : Add a new class under app_code\eService\LookUpData.cs
public class LookUpData
{
public LookUpData()
{
}
private String lookupId;
private String lookupText;
public String LookupId
{
get { return lookupId; }
set { lookupId = value; }
}
public String LookupText
{
get { return lookupText; }
set { lookupText = value; }
}
}
Step 2 : Modify AttributeData.cs and following code towards the end
public sealed class LookupAttributeData : AttributeData
{
private List
public List
{
get { return lookupOptions; }
set { lookupOptions = value; }
}
}
Step 3 : Modify MetadataUtility.cs and add following method
public static List
{
EntityMetadata entityMetadata = GetEntityMetadata(service, entityName);
String primaryAttribute = entityMetadata.PrimaryField;
String primaryKeyName=entityMetadata.PrimaryKey;
List
QueryExpression query = new QueryExpression();
query.EntityName = entityName;
query.AddOrder(primaryAttribute, OrderType.Ascending);
ColumnSet columns = new ColumnSet();
columns.AddColumns(new String[] { primaryAttribute });
query.ColumnSet = columns;
ConditionExpression condition1 = new ConditionExpression();
condition1.AttributeName = "statecode";
condition1.Operator = ConditionOperator.Equal;
condition1.Values = new object[] { 0 };
query.Criteria = new FilterExpression();
query.Criteria.FilterOperator = LogicalOperator.And;
query.Criteria.AddCondition(condition1);
RetrieveMultipleRequest request = new RetrieveMultipleRequest();
request.Query = query;
request.ReturnDynamicEntities = true;
RetrieveMultipleResponse response = (RetrieveMultipleResponse)crmService.Execute(request);
foreach (BusinessEntity item in response.BusinessEntityCollection.BusinessEntities)
{
DynamicEntity entity = (DynamicEntity)item;
if (entity.Properties.Contains(primaryAttribute))
{
LookUpData lkp = new LookUpData();
lkp.LookupText=((String)entity.Properties[primaryAttribute]);
lkp.LookupId = ((Key)entity.Properties[primaryKeyName]).Value.ToString();
results.Add(lkp);
}
}
return results;
}
Step 4: Modify the DynamicEntityUtility and Modify following function in this class
public static List
Step 5: Add following code just after Case statement AttributeType.Lookup:
case AttributeType.Lookup:
LookupAttributeData lookupData = new LookupAttributeData();
String relatedEntityName=((LookupAttributeMetadata)metadata).Targets[0].ToString();
lookupData.LookupOptions=MetadataUtility.GetLookUpDataByEntity(metadataService, relatedEntityName, service);
data = lookupData;
break;
Step 6 : Now goto Controls\EntityEditor.ascx
You need to modify following function
private WebControl GetPopulatedControl(AttributeData attributeData, String defaultValue)
Add following code within switch statement
case AttributeType.Lookup:
LookupAttributeData lookuplistAttributeData = attributeData as LookupAttributeData;
DropDownList listLookup = new DropDownList();
listLookup.ID = attributeData.SchemaName;
listLookup.CssClass = "msa-Global-SelectList";
listLookup.Attributes.Add("attributeType", lookuplistAttributeData.AttributeType.Value.ToString());
listLookup.Attributes.Add("defaultValue", (lookuplistAttributeData.ActualValue ?? 0).ToString());
listLookup.Items.Add(new ListItem());
foreach (LookUpData option in lookuplistAttributeData.LookupOptions)
{
listLookup.Items.Add(new ListItem(option.LookupText, option.LookupId));
}
if (!String.IsNullOrEmpty(lookuplistAttributeData.DisplayValue))
{
listLookup.Items.FindByText(lookuplistAttributeData.DisplayValue).Selected = true;
}
return listLookup;
Step 7 : Modify following function
public void SaveEntity()
Add following code within switch statement
case AttributeType.Lookup:
DropDownList lookuplist = (DropDownList)control;
string selectedlkpValue ="";
if (lookuplist.SelectedItem != null)
{
selectedlkpValue = lookuplist.SelectedItem.Value;
}
if (selectedlkpValue != "")
{
LookupProperty prop = new LookupProperty();
prop.Name = attribute;
prop.Value = new Lookup();
prop.Value.Value = new Guid(selectedlkpValue);
entity.Properties.Add(prop);
}
break;
By doing the above steps you should be able to display Lookup data in eService Accelerator and save back the changes.