private void EraseTextFieldData(string fieldName)
        {
            ///Get all entities and entityId...
            ///add them to an expando object....
            ///Loop the entities to update the records...
            Task.Run(async() =>
            {
                const string fetchXml
                    = "<fetch><entity name='contact'><all-attributes/></entity></fetch>";
                var fetchResults = await _api.GetList("contacts",
                                                      new CRMGetListOptions
                {
                    FetchXml = fetchXml
                });

                var myListTrackChanged = fetchResults.TrackChangesLink;
                Console.WriteLine("the tracked changes are: " + myListTrackChanged);
                myFetchResults = fetchResults.List.Count;

                myApiCount = await _api.GetCount("contacts");


                //var getEntityFetchRecords = await _api.GetList(_entityName + "s", new CRMGetListOptions
                //{

                //    FormattedValues = true
                //});

                //if (getEntityFetchRecords.List.Count > 0)
                //{
                //    foreach (var entities in getEntityFetchRecords.List)
                //    {
                //        Console.WriteLine("The number of entities is: " + entities.ToList().Count);
                //        foreach (var entity in entities)
                //        {
                //            if (entity.Key == "value") continue;
                //            if (entity.Key == fieldName)
                //            {
                //                var updateObj = new ExpandoObject() as IDictionary<string, object>;
                //                updateObj.Add(fieldName, string.Empty);
                //                await _api.Update(_entityName, _entityId, updateObj);
                //            }
                //        }
                //    }
                //}
            }).Wait();
            Console.WriteLine("The fetch results is: " + myFetchResults);
        }
Exemple #2
0
        public static async Task GetAllAccountCounts(CRMWebAPI api, ITurnContext <IMessageActivity> context)
        {
            await Task.Run(async() =>
            {
                var count = await api.GetCount("accounts");
                var card  = new HeroCard();

                var action = new CardAction()
                {
                    Type  = ActionTypes.MessageBack,
                    Title = $"Accounts in CRM: {count}",
                    Value = count.ToString()
                };
                card.Buttons = new List <CardAction>();
                card.Buttons.Add(action);
                await DisplayMessage(card, context);
            });
        }