private Property SetEntityMetadataProperties(Property prop, CRMEntityMetadata task) { if (task != null) { switch (prop.Name.ToLower()) { case "entitylogicalname": prop.Value = task.LogicalName; break; case "entitydisplayname": prop.Value = task.DisplayName; break; case "entityobjecttypecode": prop.Value = task.ObjectTypeCode; break; case "entityprimaryidattribute": prop.Value = task.PrimaryIdAttribute; break; case "entityprimarynameattribute": prop.Value = task.PrimaryNameAttribute; break; case "entityiscustomentity": prop.Value = task.IsCustomEntity; break; } } return(prop); }
private void GetEntityAttributes(ref ServiceObject so) { SourceCode.SmartObjects.Services.ServiceSDK.Objects.Method meth = so.Methods[0]; CRMEntityMetadata entitymetadata = new CRMEntityMetadata(); entitymetadata.Config = crmconfig; try { entitymetadata.LogicalName = NotNull(so.Properties["EntityLogicalName"].Value); entitymetadata.IncludeAttributes = true; CRMEntityMetadata response = CRMFunctions.CRMGetEntityMetadata(entitymetadata); so.Properties.InitResultTable(); foreach (CRMAttribute ret in response.Attributes) { for (int c = 0; c < meth.ReturnProperties.Count; c += 1) { Property prop = so.Properties[meth.ReturnProperties[c]]; prop = SetGetEntityAttributeProperties(prop, ret); } so.Properties.BindPropertiesToResultTable(); } } catch (Exception ex) { throw; } }
private void GetEntityMetadata(ref ServiceObject so) { SourceCode.SmartObjects.Services.ServiceSDK.Objects.Method meth = so.Methods[0]; //K2CRMHelper helper = new K2CRMHelper(); WizardFunctions helper = new WizardFunctions(); CRMEntityMetadata entitymetadata = new CRMEntityMetadata(); entitymetadata.Config = crmconfig; try { entitymetadata.LogicalName = NotNull(so.Properties["EntityLogicalName"].Value); entitymetadata.IncludeAttributes = false; RestResponse <CRMEntityMetadata> response = helper.GetEntityMetadata(entitymetadata, config); so.Properties.InitResultTable(); for (int c = 0; c < meth.ReturnProperties.Count; c += 1) { Property prop = so.Properties[meth.ReturnProperties[c]]; prop = SetEntityMetadataProperties(prop, response); } so.Properties.BindPropertiesToResultTable(); } catch (Exception ex) { throw; } }
private void btnGetAttributes_Click(object sender, RoutedEventArgs e) { CRMEntityMetadata emd = cbEntities.SelectedItem as CRMEntityMetadata; CRMEntityMetadata md = new CRMEntityMetadata(); md.LogicalName = emd.LogicalName; md.IncludeAttributes = true; cbAttributes.ItemsSource = functions.CRMGetEntityMetadata(md).Attributes.Where(p => p.AttributeType == "Picklist"); }
private void btnGetState_Click(object sender, RoutedEventArgs e) { CRMEntityMetadata emd = cbEntities.SelectedItem as CRMEntityMetadata; CRMAttribute att = cbAttributes.SelectedItem as CRMAttribute; CRMPicklist pl = new CRMPicklist(); pl.EntityLogicalName = emd.LogicalName; cbState.ItemsSource = functions.CRMGetStateStatus(pl).Picklist; }
private void btnGetPicklist_Click(object sender, RoutedEventArgs e) { CRMEntityMetadata emd = cbEntities.SelectedItem as CRMEntityMetadata; CRMAttribute att = cbAttributes.SelectedItem as CRMAttribute; CRMPicklist pl = new CRMPicklist(); pl.AttributeLogicalName = att.LogicalName; pl.EntityLogicalName = emd.LogicalName; CRMPicklist cp = functions.CRMGetPicklist(pl); cbOptions.ItemsSource = cp.Picklist.OrderByDescending(p => p.PicklistParentValue).OrderBy(p => p.PicklistValue); }
public CRMEntityMetadata CRMGetEntityMetadata(CRMEntityMetadata crmEntityMetadata) { CRMFunctions function = new CRMFunctions(crmEntityMetadata.Config); return(function.CRMGetEntityMetadata(crmEntityMetadata)); }