This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Reflection; | |
using System.Runtime.CompilerServices; | |
using System.Runtime.InteropServices; | |
// General Information about an assembly is controlled through the following | |
// set of attributes. Change these attribute values to modify the information | |
// associated with an assembly. | |
[assembly: AssemblyTitle("DemoCodeNoProxy")] | |
[assembly: AssemblyDescription("")] | |
[assembly: AssemblyConfiguration("")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[EntityLogicalName("account")] | |
public class MyAccount : Entity | |
{ | |
public MyAccount() : base("account") { } | |
public string odx_clientcode | |
{ | |
get | |
{ | |
return this.GetAttributeValue<string>("odx_clientcode"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[EntityLogicalName("account")] | |
public class MyAccount : Entity | |
{ | |
public MyAccount() : base("account") { } | |
[AttributeLogicalName("odx_clientcode")] | |
public string odx_clientcode | |
{ | |
get | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyEntity : Entity | |
{ | |
public MyEntity(string entityName) : base(entityName) { } | |
protected string GetAttributeName(string propertyName) | |
{ | |
return "odx_" + propertyName.ToLowerInvariant(); | |
} | |
protected T GetAttribute<T>([CallerMemberName]string propertyName = null) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[EntityLogicalName("account")] | |
public class MyAccount : MyEntity | |
{ | |
public MyAccount() : base("account") { } | |
[AttributeLogicalName("odx_clientcode")] | |
public string ClientCode | |
{ | |
get => GetAttribute<string>(); | |
set => SetAttribute(value); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyEntity : Entity | |
{ | |
protected string GetAttributeName(string propertyName) | |
{ | |
return this.GetType().GetProperties().FirstOrDefault(p => p.Name == propertyName).GetCustomAttribute<AttributeLogicalNameAttribute>().LogicalName; | |
} | |
protected T GetAttribute<T>([CallerMemberName]string propertyName = null) | |
{ | |
return this.GetAttributeValue<T>(GetAttributeName(propertyName)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TransactionPlugin : IPlugin | |
{ | |
public void Execute(IServiceProvider serviceProvider) | |
{ | |
var context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext)); | |
var factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory)); | |
var service = factory.CreateOrganizationService(null); | |
var counter = GetCounter(service); | |
counter["new_name"] = "lockme"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function changeCompositeFieldLabel(attributeName, label) { | |
var attribute = Xrm.Page.getAttribute(attributeName); | |
if (attribute != null) { | |
attribute.controls.forEach(function (c) { | |
c.setLabel(label); | |
}); | |
} | |
} | |
//Usage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void Main(string[] args) | |
{ | |
var solutionUniqueName = "SOLUTIONNAME"; | |
var orgService = new CrmServiceClient(ConfigurationManager.ConnectionStrings["CRM"].ConnectionString); | |
var solutionComponentQuery = new QueryExpression("solutioncomponent"); | |
solutionComponentQuery.Distinct = true; | |
solutionComponentQuery.ColumnSet.AddColumns("objectid", "componenttype", "solutioncomponentid"); | |
var solutioncomponentSolutionLink = solutionComponentQuery.AddLink("solution", "solutionid", "solutionid"); | |
solutioncomponentSolutionLink.EntityAlias = "aa"; | |
solutioncomponentSolutionLink.LinkCriteria.AddCondition("uniquename", ConditionOperator.Equal, solutionUniqueName); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var activityId = "059C0532-906C-E711-9409-00155D018D00"; | |
var activityType = "appointment"; //or any other entity type | |
var entity = {}; | |
entity["objectid_activitypointer@odata.bind"] = "/activitypointers(" + activityId + ")"; | |
entity.body = "ZGZnZA=="; //your file encoded with Base64 | |
entity.filename = "test"; | |
entity.subject = "test"; | |
entity.objecttypecode = activityType; |