I built a web api using C# to communicate to CRM . I was successful to retrieve accounts. What I want to do is I want to retrieve the events from the CRM . I think I have to create entity for the events in the crm but how can I do that?
This is the code for the accounts
ColumnSet colsPrincipal = new ColumnSet("lastname", "firstname", "domainname", "systemuserid", "businessunitid");
QueryExpression queryPrincipal = new QueryExpression();
queryPrincipal.EntityName = "event";//systemuser
queryPrincipal.ColumnSet = colsPrincipal;
var myAccounts = CommonCrm.crmContext.RetrieveMultiple(queryPrincipal);
foreach (var myEntity in myAccounts.Entities)
{
//create new crm users and add it to the list
CrmUser thisOne = new CrmUser();
thisOne.firstName = myEntity.GetAttributeValue<string>("firstname");
thisOne.lastName = myEntity.GetAttributeValue<string>("name");
thisOne.userId = myEntity.GetAttributeValue<string>("domainname");
thisOne.userGuid = myEntity.GetAttributeValue<Guid>("systemuserid");
thisOne.buId = myEntity.GetAttributeValue<EntityReference>("businessunitid").Id;
// and so on and so forth...
Console.Write(thisOne.firstName + " " + thisOne.userGuid + " " + thisOne.lastName);
CrmUsers.Add(thisOne);
arra.Add(thisOne.firstName);
}
The easiest way, via CRM Customizations and Solutions. As it is a pretty huge topic, I'd recommend you getting started with this link
Related
I am using this C# SDK to get data from Dynamics CRM 2011: https://msdn.microsoft.com/en-us/library/gg695803(v=crm.5).aspx
I need to read all the Accounts from it, the problem is, there are many accounts that are deactivated.
To get the accounts I am using the following code:
var accounts = xrm.AccountSet
.Select(acc => new
{
name = acc.Name,
guid = acc.AccountId,
parent = acc.ParentAccountId,
number = acc.AccountNumber,
website = acc.WebSiteURL,
});
This way has been suggested in this question: Retrieve list of all accounts in CRM through C#?
The problem is, this gets me all the accounts, both active and deactivated accounts. Is there any way to differentiate betweet those two?
Try something like:
var accounts = xrm.AccountSet.Where(acc => acc.StatusCode.Value == 0)
.Select(acc => new
{
name = acc.Name,
guid = acc.AccountId,
parent = acc.ParentAccountId,
number = acc.AccountNumber,
website = acc.WebSiteURL,
status = acc.StatusCode
});
For anyone wondering, I found the solution.
There is a StatusCode Field for each Account. Just extract it and check its value later.
var accounts = xrm.AccountSet
.Select(acc => new
{
name = acc.Name,
guid = acc.AccountId,
parent = acc.ParentAccountId,
number = acc.AccountNumber,
website = acc.WebSiteURL,
status = acc.StatusCode
});
Is there any other way?
How to connect couchDB with ASP.NET C# application? If any one can you give a sample application.
I had the same need and after evaluating the options available, to meet the requirements of my application, I created any components that helped me a lot and maybe they can help you and also others. I make it clear that I have no intention of promoting myself here, just sharing something that may be useful.
The detailed explanation of how to configure and use it is on Github.
Link: Nuget Package |
Github
Example of use for retrieving documents with mango-querie:
IList<User> users;
var sts = new List<String> { "ACTIVE", "LOCKED" };
using (UserRepository db = new UserRepository())
{
var query = db.FindOf("list-status", new { id = "OwnerIdloop.user.7", statuses = sts });
users = db.List<User>(query);
}
Array.ForEach(users.ToArray(), Console.WriteLine);
Example of adding documents:
User user = createUser("email#email.com");
using (UserRepository db = new UserRepository())
{
var result = db.Insert<User>(user); // add document and return instance changed with operation revision id
Console.WriteLine(result.Revision);
}
Example of changing documents:
using (UserRepository db = new UserRepository())
{
// Load document data by ID
var user = db.Get<User>("email#email.com");
user.Name = user.Name + "::CHANGED";
var result = db.Update<User>(user); // update document and return instance changed with operation revision id
Console.WriteLine(result.Revision);
}
Example of deleting documents:
using (UserRepository db = new UserRepository())
{
// Load document data by ID
var user = db.Get<User>("email#email.com");
var result = db.Delete<User>(user); // delete document from database. Return true case sucess or false case not deleted
Console.WriteLine($"Sucesso: {result}");
}
After installing the NuGet, just create an instance of MyCouch.Client and pass it the URL of your database.
using (var client = new MyCouchClient("http://127.0.0.1:5984/test"))
{
//Consume here
}
The format is: {scheme}://[{username}:{password}]/{authority}/{localpath}. From v0.11.0, there's a specific MyCouchUriBuilder that you can use for building the Uri. It will automatically e.g. apply Uri.EscapeDataString to username and password when calling SetBasicCredentials.
var uriBuilder = new MyCouchUriBuilder("http://localhost:5984/")
.SetDbName(TestConstants.TestDbName)
.SetBasicCredentials("foob#r", "p#ssword");
return new MyCouchClient(uriBuilder.Build());
For more details Click Here
I'm new to the Rally world and am struggling through how to use the RallyRestAPI. There are a number of examples of how to query Rally to get back pertinent information that I have found most helpful. What I'm trying to do is create a C# command line tool to add users to a project. It appears that I use the RallyRestAPI.Create("projectpermission",some dynamic json object) interface to accomplish the creation. My problem is understanding the "some dynamic json object" part. I'm not sure how to correctly set it up. If someone has a small example of how to set it up, I would appreciate it.
Here's a code sample illustrating how to do this. Note that:
UserID running the code to create permissions must be a Workspace or Subscription Administrator
User must already have permissions in the Workspace (i.e be a Workspace User) in order for the ProjectPermission creation to succeed
namespace RestExample_AddUsersToProject {
class Program
{
static void Main(string[] args)
{
String userName = "user#company.com";
String userPassword = "topsecret";
String serverUrl = "https://rally1.rallydev.com";
String wsapiVersion = "1.38";
RallyRestApi restApi = new RallyRestApi(
userName,
userPassword,
serverUrl,
wsapiVersion
);
restApi.Headers[RallyRestApi.HeaderType.Vendor] = "Rally Software";
restApi.Headers[RallyRestApi.HeaderType.Name] = "RestExample_AddUsersToProject";
// Query for Project for which we want to add permissions
Request projectRequest = new Request("project");
projectRequest.Fetch = new List<string>()
{
"Name",
"Owner",
"State",
"Description"
};
String projectName = "Avalanche Hazard Mapping";
projectRequest.Query = new Query("Name", Query.Operator.Equals, projectName);
QueryResult queryProjectResults = restApi.Query(projectRequest);
var myProject = queryProjectResults.Results.First();
String myProjectReference = myProject["_ref"];
Console.WriteLine("Project Name: " + myProject["Name"]);
Console.WriteLine("State: " + myProject["State"]);
// Query for User for whom we wish to add ProjectPermission
Request userRequest = new Request("user");
userRequest.Fetch = new List<string>()
{
"UserName",
"Subscription",
"DisplayName"
};
// User needing the permissions
userRequest.Query = new Query("UserName", Query.Operator.Equals, "\"boromir#midearth.com\"");
QueryResult queryUserResults = restApi.Query(userRequest);
var myUser = queryUserResults.Results.First();
String myUserReference = myUser["_ref"];
Console.WriteLine("Username: " + myUser["UserName"]);
Console.WriteLine("Display Name: " + myUser["DisplayName"]);
Console.WriteLine("Subscription: " + myUser["Subscription"]);
// Setup required ProjectPermission data
DynamicJsonObject newProjectPermission = new DynamicJsonObject();
newProjectPermission["User"] = myUser;
newProjectPermission["Project"] = myProject;
newProjectPermission["Role"] = "Editor";
// Create the permission in Rally
CreateResult addProjectPermissionResult = restApi.Create("ProjectPermission", newProjectPermission);
DynamicJsonObject fetchedProjectPermission = restApi.GetByReference(addProjectPermissionResult.Reference, "Name");
Console.WriteLine("Created ProjectPermission with Role: " + fetchedProjectPermission["Name"]);
}
}
}
There are some very basic examples of CRUD + querying here:
http://developer.rallydev.com/help/rest-api-net
The general flow will always be to create a new DynamicJsonObject, set the appropriate fields and then pass that object to the Create method of an RallyRestApi.
Good day all.
Does anyone has a working example how to make Google Plus post through .NET (C#).
I have already tried google and stackoverflow search, but did not manage to find the solution.
I successfully get posts:
public void Post(string text)
{
PlusService plus = new PlusService {Key = "MYVERYSECRETKEY"};
ActivitiesResource ar = new ActivitiesResource(plus, null);
ActivitiesResource.ListRequest list = ar.List("108055870103885325249", new ActivitiesResource.Collection());
ActivityFeed feed = list.Fetch();
string activityKey = "";
foreach (var a in feed.Items)
if (a.Url == "https://plus.google.com/108055870103885325249/posts/EtvvUgn8eKz")
{
activityKey = a.Id;
break;
}
ActivitiesResource.GetRequest get = ar.Get(activityKey);
Activity act = get.Fetch();
var sb = new System.Text.StringBuilder();
sb.AppendLine("Title: " + act.Title);
sb.AppendLine("URL:" + act.Url);
sb.AppendLine("Published:" + act.Published);
sb.AppendLine("By:" + act.Actor.DisplayName);
sb.AppendLine("Annotation:" + act.Annotation);
sb.AppendLine("Content:" + act.Object.Content);
sb.AppendLine("Type:" + act.Object.ObjectType);
sb.AppendLine("# of +1s:" + act.Object.Plusoners.TotalItems);
sb.AppendLine("# of reshares:" + act.Object.Resharers.TotalItems);
}
But I cannot find any method for making posts.
Thanks in advance.
Currently, the Google+ API does not allow writing of posts to a user's activity stream. You can use the moments.insert method in the Google+ REST API to write App Activities to the user's profile, which the user can choose whether to share publicly or to their circles.
You would work with the REST API in a similar manner to other REST APIs in .NET by POSTing to the moments.insert end-point.
This feature is now available to apps that request the https://www.googleapis.com/auth/plus.login scope and specify the type of moments that the app wants to write in the request_visible_actions parameter either in the Google+ Sign-In button or directly in the OAuth query parameters.
I am using CRM 4.0 SDK to query kbarticles by keyword entered from a textbox on an asp.net webpage. I am using the SearchByKeywordsKbArticleRequest message to do this. Single keywords work fine, but if more than one word is entered a server error occurs. Here is my code:
CrmAuthenticationToken token = new CrmAuthenticationToken();
token.AuthenticationType = 0;
token.OrganizationName = "omitted";
CrmService service = new CrmService();
service.Url = "omitted"
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;
//RetrieveMultipleResponse allArticlesResponse = getAllArticles();
SearchByKeywordsKbArticleRequest kb = new SearchByKeywordsKbArticleRequest();
String rawSearchText = keyword;
ColumnSet col = new ColumnSet();
col.Attributes = new string[] { "title", "kbarticleid" };
kb.ColumnSet = col;
kb.SearchText = rawSearchText.Trim();
kb.ReturnDynamicEntities = false;
SearchByKeywordsKbArticleResponse response =
(SearchByKeywordsKbArticleResponse)service.Execute(kb);
return response.BusinessEntityCollection;
Any clues?
That method uses the SQL Full-Text indexing service, so you would need to have full-text indexing setup in your database. You should be able to get more information about what's going wrong by enabling tracing in CRM. See:
http://social.microsoft.com/forums/en-us/crmdevelopment/thread/6A4CE7A3-29F3-4E5A-9A89-8E35D6FD05B9