Posts

Showing posts from 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(".tx...

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);           ...

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>();   ...

Custom Workflow (Real Time Workflow) with Input and OutPut Parameters in D365

Image
using Microsoft.Xrm.Sdk; 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 CustomWorkflowAgeCalByDOB {     //DOB Calculate by using custom workflow (Real Time Workflow) with Input and OutPut Parameters     /// <summary>     /// Register a Workflow on Contact Entity on Create or Update(DOB filed) Event     /// Create fields DOB DateTime and Age,Days of WholeNumber type in Contact entity     /// Select the Custom workflow and fill the DOB     /// In Update step Setproperties Age and day field     /// </summary>     public class Class1 : CodeActivity     {         [ Input ( "Date of Birth" )]    ...

How to get the Impersonation User Id(systemUserId ) in D365

public Guid getUserId(IOrganizationService service, string userName)         {             Guid systemUserId = Guid.Empty;             try             {                 QueryByAttribute queryByAttribute = new QueryByAttribute("systemuser");                 ColumnSet columns = new ColumnSet("systemuserid");                 queryByAttribute.AddAttributeValue("fullname", userName);                 EntityCollection retrieveUser = service.RetrieveMultiple(queryByAttribute);                 systemUserId = ((Entity)retrieveUser.Entities[0]).Id;             }             catch (FaultException<OrganizationServiceFaul...

Get OptionSet Text from Value and Get Optionset Value from Text in MS CRM using C#

using Microsoft.Xrm.Sdk; using Microsoft.Xrm.Sdk.Messages; using Microsoft.Xrm.Sdk.Metadata; using Microsoft.Xrm.Sdk.Query; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AkithaCaseQuoteOptionset {     public class CreateQuoteFromCase:IPlugin     {         public void Execute(IServiceProvider serviceProvider)         {             ITracingService trace = (ITracingService)serviceProvider.GetService(typeof(ITracingService));             IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));             IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));             ...

Retrieve account related views using Web API request

//Retrieve account related views using Web API request /api/data/v8.2/savedqueries?$filter=returnedtypecode eq 'account' //retrieve account active view name and id /api/data/v8.2/savedqueries?$select=name,savedqueryid&$filter=name eq 'Active Accounts'

Dynamically adding row to table and selected entity related attributes to table dynamically using html in mscrm

<html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head></head> <body>          <meta charset="utf-8">     <title>Sample page</title>     <script src="../../ClientGlobalContext.js.aspx" type="text/javascript"></script>     <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>     <script src="http://managed.apy.com:5555/apyuthorities/WebResources/mtcsv_/Scripts/Jquery.1.8.2.min.js"></script>     <script src="http://managed.apy.com:5555/apyuthorities/WebResources/apy_Sdknew.js" type="text/javascript"></script>     <!--<script src="Scripts/SDK.MetaData.js" type="text/javascript"></script>-->     <script src="http://managed.apy.com:5555/apy/WebResources/apy_XrmSvcToolkit.js" type="text/javascript"...