In the following documentation, it states that you can
...provide arbitrary key/value pairs beyond the reserved names and those will be stored with the user
In C# code, I have the following:
var _user = new {
Login = "fred",
EmailAddress = "fred#here.com",
Name = "Fred Flintstone"
}
SentrySdk.ConfigureScope( scope => {
scope.User = new Sentry.Protocol.User()
{
Id = _user.Login,
Email = _user.EmailAddress,
Username = _user.Login
};
});
Is there a way to add Name (or any other field)? Or is the documentation just referring to tags?
You can add your custom user data via the Other property.
The latest version of the Sentry.Protocol has Other as a IReadOnlyDictionary which means you need to assign a new instance like:
var sut = new User
{
Id = "user-id",
Email = "test#sentry.io",
IpAddress = "::1",
Username = "user-name",
Other = new Dictionary<string, string>
{
{"Name", "your name"},
{"anything else", "whatever"},
}
};
This PR is making Other mutable so you can add data like:
var user = new User();
user.Other.Add("key", "value");
Related
I am getting error - no service provision, someone with experience please help me.
var clinic = new new_clinic();
clinic.new_name = "Medinet";
Account trust = new Account();
trust.Name = "bIRMINGHAM CITY hOSPITAL";
Guid trustID = (Guid)Service().Create(trust);
CrmEntityReference clinic_trust = new CrmEntityReference(trust.LogicalName, trustID);
clinic.new_Trust = clinic_trust;
clinic.new_ClinicDate = DateTime.Now;
new_hospital hospital = new new_hospital();
hospital.new_name = "Geek-guru";
Service().Create(hospital);
Guid hospitalID = (Guid)hospital.Id;
clinic.new_HostingHospital = new CrmEntityReference(hospital.LogicalName, hospitalID);
clinic.new_ClinicDate = new DateTime(2018, 07, 28);
new_serviceprovision ser_contract = new new_serviceprovision();
ser_contract.new_Trust = clinic_trust;
ser_contract.new_Specialty = new OptionSetValue(100000018);
Service().Create(ser_contract);
Guid ser_con_id = (Guid)ser_contract.Id;
clinic.new_ServiceContract = new CrmEntityReference(ser_contract.LogicalName, ser_con_id);
// Account account = (Account)GetOrgService().Retrieve(trust.LogicalName, trustID, new Microsoft.Xrm.Sdk.Query.ColumnSet("name"));
//retreive the default business unit needed to create the user
QueryExpression businessUnitQuery = new QueryExpression
{
EntityName = BusinessUnit.EntityLogicalName,
ColumnSet = new ColumnSet("businessunitid"),
Criteria = { Conditions = { new ConditionExpression("parentbusinessunitid", ConditionOperator.Null) } }
};
BusinessUnit businessUnit = Service().RetrieveMultiple(businessUnitQuery).Entities[0].ToEntity<BusinessUnit>();
//creating a user
SystemUser systemUser = new SystemUser();
systemUser.DomainName = "" + "Chika";
systemUser.FirstName = "Olabajo";
systemUser.LastName = "Boss";
systemUser.InternalEMailAddress = "onyebuchi#gmail.com";
systemUser.BusinessUnitId = new EntityReference(BusinessUnit.EntityLogicalName, businessUnit.Id);
Guid systemID = (Guid)Service().Create(systemUser);
// systemUser = (SystemUser)Service().Retrieve(systemUser.LogicalName, systemID, new Microsoft.Xrm.Sdk.Query.ColumnSet("fullname"));
//this field is a lookup field to User. Assigned to the user created above
clinic.new_ClinicCoordinator = new CrmEntityReference(systemUser.LogicalName, systemID);
clinic.new_BookedBy = new OptionSetValue(100000001);
clinic.new_Type1 = new OptionSetValue(100000008);
clinic.new_Type2 = new OptionSetValue(100000001);
clinic.new_NumberofConsultants = 5;
clinic.new_NumberofNursesSuppliedByTrust = 6;
Service().Create(clinic);//getting error here
MessageBox.Show("Sucessfully added a clinic record");
I have been on these for weeks now, I would appreciate a little bit of help.
I am now having "no serviceprivison issue", A user has now been created, but still gettting error.
Go step by step. You have 3 things one after other like Creating user, Retrieving FullName column, then updating clinic.new_ClinicCoordinator field. Comment out the 2 steps & verify if user is getting created or not, if created successfully then retrieve next (this is not needed as you already have systemID which is needed for update)
Use try catch for better exception handling in code
Edit: CRM online interactive user cannot be created in code. Read more
Update:
Merge the below lines, as ser_contract object is not updated back with created Guid. Do the same for hospitalID as well.
Service().Create(ser_contract);
Guid ser_con_id = (Guid)ser_contract.Id;
This should be working:
Guid ser_con_id = Service().Create(ser_contract);
I have successfully connected my ASP.NET MVC5 C# project to QuickBooks Online through Oauth, and the "IPP .NET SDK for QuickBooks V3" NuGet Package.
I can add new customers, and everything works fine. However, if I try to add a customer that already exists, it throws the following error: "ValidationException was thrown".
My question is, what is the best way to check if the customer already exists in QuickBooks before trying to add them, so as to avoid the exception?
This is the code I have that adds the new customer to QuickBooks:
OAuthRequestValidator oauthValidator = new OAuthRequestValidator(accessToken, accessTokenSecret, consumerKey, consumerSecret);
ServiceContext context = new ServiceContext(realmId, intuitServicesType, oauthValidator);
DataService dataService = new DataService(context);
var customer = new Customer();
customer.GivenName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(submission.FirstName.ToLower());
customer.FamilyName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(submission.LastName.ToLower());
customer.BillAddr = new PhysicalAddress()
{
Line1 = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(submission.Address.ToLower()),
City = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(submission.City.ToLower()),
CountrySubDivisionCode = submission.State,
PostalCode = submission.ZipCode
};
customer.PrimaryEmailAddr = new EmailAddress() { Address = submission.EmailAddress.ToLower(), Default = true };
customer.PrimaryPhone = new TelephoneNumber() { FreeFormNumber = submission.Phone };
dataService.Add(customer);
Editted to add my solution with the answer from #Keith Palmer
OAuthRequestValidator oauthValidator = new OAuthRequestValidator(accessToken, accessTokenSecret, consumerKey, consumerSecret);
ServiceContext context = new ServiceContext(realmId, intuitServicesType, oauthValidator);
// Check if the customer already exists in QuickBooks
QueryService<Customer> customerQueryService = new QueryService<Customer>(context);
int customerCount = customerQueryService.Where(c => c.GivenName == submission.FirstName && c.FamilyName == submission.LastName).Count();
if (customerCount == 0)
{
// If not, then add the new customer.
DataService dataService = new DataService(context);
var customer = new Customer();
customer.GivenName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(submission.FirstName.ToLower());
customer.FamilyName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(submission.LastName.ToLower());
customer.BillAddr = new PhysicalAddress()
{
Line1 = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(submission.Address.ToLower()),
City = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(submission.City.ToLower()),
CountrySubDivisionCode = submission.State,
PostalCode = submission.ZipCode
};
customer.PrimaryEmailAddr = new EmailAddress() { Address = submission.EmailAddress.ToLower(), Default = true };
customer.PrimaryPhone = new TelephoneNumber() { FreeFormNumber = submission.Phone };
dataService.Add(customer);
}
else
{
TempData["Warning"] = "The customer already exists in QuickBooks.";
return RedirectToAction("Estimates", "Admin");
}
Query for the customer to see if they exist before adding them.
What you query for (Name, Email, etc.) is dependent on how you want to implement your application/what your customer wants.
Per the docs:
https://developer.intuit.com/docs/0100_quickbooks_online/0400_tools/0005_sdks/0010.net_tools/0030_query_filters
Your code should look something like this:
IEnumerable customers = invoiceQueryService.Where(c => c.Balance > 1000);
You can refer to the object reference to see which fields you can filter by:
https://developer.intuit.com/docs/api/accounting/customer
I am very new to MS-CRM and I want to retreive all the details of the contact
var executeQuickFindRequest = new OrganizationRequest("ExecuteQuickFind");
executeQuickFindRequest.Parameters = new ParameterCollection();
var entities = new List<string> { "contact", "lead", "account" }; //specify search term
executeQuickFindRequest.Parameters.Add("SearchText", "maria");
//will cause serialisation exception if we don't convert to array
executeQuickFindRequest.Parameters.Add("EntityNames", entities.ToArray());
var executeQuickFindResponse = _orgService.Execute(executeQuickFindRequest);
var result = executeQuickFindResponse.Results;
The data here displayed contains display name's such as address_1_City,email_user
However I want to get there actual names like Address,Email etc etc.
Thanks
Just to extend what BlueSam has mentioned above.
EntityMetadata entityMetaData = retrieveEntityResponse.EntityMetadata;
for (int count = 0; count < entityMetaData.Attributes.ToList().Count; count++)
{
if (entityMetaData.Attributes.ToList()[count].DisplayName.LocalizedLabels.Count > 0)
{
string displayName = entityMetaData.Attributes.ToList()[count].DisplayName.LocalizedLabels[0].Label;
string logicalName = entityMetaData.Attributes.ToList()[count].LogicalName;
AttributeTypeCode dataType = (AttributeTypeCode)entityMetaData.Attributes.ToList()[count].AttributeType;
}
}
Above code will help you to get the display name, logical name and data type for each attribute in the entity. Similarly you can get other information as well from the entityMetaData object as per above code snippet.
As far as I know, you will need to pair it up with the attributes of the entities that are for that request. Here's a sample of how to retrieve an entity:
RetrieveEntityRequest retrieveBankAccountEntityRequest = new RetrieveEntityRequest
{
EntityFilters = EntityFilters.Entity,
LogicalName = entityName
};
RetrieveEntityResponse retrieveEntityResponse = (RetrieveEntityResponse)_serviceProxy.Execute(retrieveBankAccountEntityRequest);
You can do it easy as below
using (var service = new OrganizationService(CrmConnection.Parse("CRMConnectionString")))
{
var Res = service.Retrieve("sv_answer", new Guid("GUID Of Record"), new ColumnSet("ColumnName "));
}
Code:
// To create a User Story
var collectionUri = new Uri(txtTFS.Text);
var tpc = new TfsTeamProjectCollection(collectionUri);
var workItemStore = tpc.GetService<WorkItemStore>();
var teamProject = workItemStore.Projects[txtSelectedProject.Text];
var typeWorkItem = ConfigurationManager.AppSettings["WorkItemType"];
var workItemType = teamProject.WorkItemTypes[typeWorkItem];
var userStory = new WorkItem(workItemType)
{
Title = "Test Title",
Description = "Test Description",
IterationPath = "xx\\yy\\zz",
AreaPath = "xxx\\yyy\\zzz",
State = "New",
// "AssignedTo" field not populated here...
};
// Save the new user story.
userStory.Save();
How to set value in "AssignedTo" field in TFS programatically while creating a UserStory?
Only the fields that are on every work item type have their own property on the WorkItem class.
You should use the WorkItem.Fields property to access any field that are not properties.
userStory.Fields["System.AssignedTo"].Value = "JJJ";
You cannot really use properties with indexers inside object intialiser syntax so you will have to have then on a new line before .Save();
We can write 1 dimensional json-object in csharp like this
var Obj = new { username = "Test", password = "TEST" };
How would you write the two dimensional json-object, something like
var Obj = new { username: {[username:"Test", password: "TEST"]}, key:{[Key1:"OK"]} };
What you are creating is not actually a JSON object. It has nothing to do with JSON, though I can see why you thing it does based on the syntax. It is actually an anonymous type.
You can nest these types inside each other, like so (translating your example):
var Obj = new
{
username = new
{
username = "Test",
password = "TEST"
},
key = new
{
Key1 = "OK"
}
};