/// <summary> /// This method is called when user clicks a record /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void lvList_ItemClick(object sender, ItemClickEventArgs e) { EntityReferenceCollection references = new EntityReferenceCollection(); // Associate selections EntityReference refRecord = new EntityReference(); refRecord.LogicalName = (string.IsNullOrEmpty((e.ClickedItem as ViewData).ActivityTypeName)) ? (CRMGrid.cbLookFor.SelectedItem as EntityMetadataEx).EntityMetadata.LogicalName : (e.ClickedItem as ViewData).ActivityTypeName; refRecord.Id = (e.ClickedItem as ViewData).Id; references.Add(refRecord); await CRMHelper.Associate(record.LogicalName, record.Id, new Relationship(relatedData.SchemaName), references); if (Frame.CanGoBack) { Frame.GoBack(); } }
/// <summary> /// This method is called when user clicks Associate Button /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void abAssociate_Click(object sender, RoutedEventArgs e) { EntityReferenceCollection references = new EntityReferenceCollection(); // Associate selections foreach (ViewData item in CRMGrid.lvList.SelectedItems) { EntityReference refRecord = new EntityReference(); refRecord.LogicalName = (string.IsNullOrEmpty(item.ActivityTypeName)) ? (CRMGrid.cbLookFor.SelectedItem as EntityMetadataEx).EntityMetadata.LogicalName : item.ActivityTypeName; refRecord.Id = item.Id; references.Add(refRecord); } await CRMHelper.Associate(record.LogicalName, record.Id, new Relationship(relatedData.SchemaName), references); // Go back to original page if (Frame.CanGoBack) { Frame.GoBack(); } }