Posts

Showing posts from October, 2018

Log file create using c# in MS crm

#region NameSpaces using System.IO; using System; using System.Windows.Forms; #endregion namespace EmailAttachments {     //This is Log File     class Log     {         static string baseDirectory = CustomException.baseDirectory;         static string LogFile = "";         #region Constructor         /// <summary>         /// Parameterized Constructor         /// </summary>         public Log(string logFile)         {             try             {                 if (CustomException.HasPermissions(baseDirectory))                 {                     if (!logFile.Contains(".txt"))                     {                         logFile = logFile + ".txt";                     }                     LogFile = baseDirectory + logFile;//+"_"+DateTime.Now.ToString("MMddyyyyhhmm");                     if (!Directory.Exists(baseDirectory)) { System.IO.Directory.CreateDirectory(baseDirectory); }      

Association in mscrm

using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Xrm.Sdk; using Microsoft.Xrm.Sdk.Client; using Microsoft.Xrm.Sdk.Messages; using Microsoft.Xrm.Sdk.Query; namespace Commissions {     public class User_Commissions:IPlugin     {         public void Execute(IServiceProvider serviceProvider)         {             #region Context             IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));             IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));             IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);             ITracingService Tracing = (ITracingService)serviceProvider.GetService(typeof(ITracingService));             Tracing.Trace("Depth= " + context.Depth);             if (context.Depth > 1)    

Sharepoint folder creation Using C#

////////apconfig.xml//////////// <?xml version="1.0" encoding="utf-8" ?> <configuration>     <startup>         <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />     </startup> <appSettings>     <add key="spurl" value="https://****.crm8.dynamics.com"/>     <add key="username" value="******@***.onmicrosoft.com"/>     <add key="password" value="********"/>     <add key="entity" value="Case"/>     <add key="Path" value="C:\Sharepoint"/>   </appSettings> </configuration> ////////////helper class//////////////////////////// using Microsoft.SharePoint.Client; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SharePointManager {     public class SPServiceHelper

Example of InOut Parameter in custom workflow

using Microsoft.Xrm.Sdk; using Microsoft.Xrm.Sdk.Query; using Microsoft.Xrm.Sdk.Workflow; using System; using System.Activities; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ClassLibrary1 {     public class Program : CodeActivity     {         [Input("Value")]         public InArgument<string> Value { get; set; }         [Output("AccountId")]         public OutArgument<string> AccountId { get; set; }         protected override void Execute(CodeActivityContext context)         {             IWorkflowContext wfcontext = context.GetExtension<IWorkflowContext>();             IOrganizationServiceFactory serviceFactory = context.GetExtension<IOrganizationServiceFactory>();             IOrganizationService service = serviceFactory.CreateOrganizationService(wfcontext.InitiatingUserId);             Entity Contact = service.Retrieve(wfcontext.PrimaryEntityName,