Monday, December 1, 2014

CRM 2011 Customization/Extension : Quick Notes

Solution Export/Import

Export:
Before check if everything is working fine.
1. Select the desired solution to open and export
2. Or Create a new solution > Add only the entities, plugins, Sdk events and webresoures you need. > Export

Picklist mapping value problem
1. condition : values must be same, default value must be same

// crm 2011 report
1. if not installed , install report extension and other..
2. install the updates : CRM2011-Srs-KB2600640-DEU-amd64.exe , CRM2011-Srs-KB2600644-DEU-amd64.exe
3. For external: select report>Bearbeiten>Aktionen>Bericht für externe Verwendung veräffentlichen
    -- Open Sql Server 2008 R2: Reporting Services Configuration Manager>Webdienst-URL > click Url>selct organization>....
   
rsProcessingAborted problem resolved: http://community.dynamics.com/crm/b/crmmusings/archive/2013/01/17/crm-2011-rsprocessingaborted-error-when-running-custom-reports.aspx#.USzdNKWEzR0

-- MS SQL report builder 3.0
1. create new report or edit existing, editing existing is easier
2. Add Datasource :Data Source=localhost;Initial Catalog=xyz_MSCRM
3. Add Dataset: SQL query + parameter in Query editor. Parameter are like @param without declaration and can be used in the where clause for filtering the data.
4. Expressions can be added to get sum, specific months or year. Expressions are used to get the values after filtering the data.
5. The money fields, text, date etc can be formatted for report from the ribbon Zahl(Count)
6. Tables, Textfields, the rectangles etc. can be added to add and organize data, text and others required for the report.

12:43 13.02.2013

//crm 2011 installation
preparation: need active directory (AD DS)to be enabled for CRM 2011
1. download crm 2011 in the user defined folder "setup"
2. inside setup>crm2011 License.txt is there
3. download and unpack the crm2011-server-en-amd64 inside "crm2011" folder, keep a copy of the downloaded file inside setup folder
4. install clicking "SetupServer.exe"
Microsoft Dynamics CRM 2011 supported configurations> http://technet.microsoft.com/en-us/library/hh699704.aspx
Security considerations for Microsoft Dynamics CRM 2011> http://technet.microsoft.com/en-us/library/hh699825.aspx
5. click refresh, then select xcrm9\crm
6. Security Group: New folder named "xcrm9" for test to select during installation, here comes new folder "xcrm2" for live crm.
7. http://localhost:5555 should load the installed crm 2011 organization.

// MS SQL 2005 DB Backup and install into SQL 2008 + in crm 2011
1. RC - Database > Tasks> Backup (Sichern)
    Optionen:
    --Medium überschreiben> select: Alle vorhandenen sicherungssätze
    -- Zuverlässigkeit > Sicherung nach dem Abschluss überprüfen (verify)
    Allgemein
    -- select drive to save backup
   
2. copy the backup to the target machine
3. In target machine RC-Database> Datenbank wiederherstellen, from medium / data
Before installation Reporting server must be installed from crm 2011 folder + update rollup 8 for report
4. Target machine , Bereitstellungs manager>organization>Imort organization>select the database backup

-- Repeating Table column headers in each report pages:
    1. In the grouping pane, make sure to turn on advanced mode (click on the small black down arrow on the far right of the grouping pane)
    2. Select the corresponding (Static) item in the row group hierarchy
    3. in the properties grid on the right:
        - set RepeatOnNewPage to true for repeating headers (only doing this served my purpose)
        - set FixedData to true for keeping headers visible
        -set KeepWithGroup to After
        /// ///
//Sql 2008 time scheduler task
1. used testdb>sicherheit>schemas>db_owner>properties : Berechtigungen>schema name: db_owner.. suchen > testdb\AdminCrm, erteilen: all
2. on task properties: use admin crm, select the right database, see if any error in the query.

//Compatibility mode: Internet explorer

When anything does not compatible, then run the Internet explorer in compatibility mode, its in the http box>onthe write>click>turns into blue

//oData query + retrieveMultiple
* Situation : 1: n relation, need a field from child entity to parent entity Ausgang
1. Use retrieve multiple in the script
2. In OData Query Designer: 

#Select Entity Set:ChildSet
# Filter Criteria: The relation id (Parent:Child= 1:n)
#eguals:guid of Parent
# Entity Attributes: Select Desired field (Datum der zahlung) 
# order by criteria: in this case the latest value , which is got from sorting descending
  --this returns an array, from where passing an object parameter the desired field/fields can be retrieved.

var query = "$select=ChildEntitySourcetField&$orderby=ChildEntitySourcetField desc&$filter=(rel.id)parentId/Id eq guid'"+Xrm.Page.data.entity.getId()+"'" //get GUId of Parent

SDK.REST.retrieveMultipleRecords(
"childEntitylogicalName", //child                   
query,
function (pos)
    {
    var daysDiff;
    if(pos.length>0)
        {
        var dateZahl=pos[0].ChildEntitySourcetField; //first element of the array
        }
        },     

function (err) { },
function (pos) { }
);


//Microsoft free software
https://www.microsoft.com/msppdd/Catalog/CatalogView.aspx


// CRM Dialog tool + Trace tool
to trace the log data, the errors and the warnings from the CRM server.
The any error in any certain point of time, are logged in the file. Seeing the time the error can be traced.

//Crm Data Import
1. Max 8 MB is better to import.
2. If the data is big enough, it must me imported by parts; every parts should be less thatn 8 MB
3. Once a mapping is done it can be saved to use for the next part.
4. CRM fields should have the same similar fields like desired data colums. thats how mapping is easier later.
5. Failed data , say 2 rows, can be corrected manually and seeing the row number and reimported onlye those 2 rows.
//CRM-Outlook field mapping
..http://blogs.msdn.com/b/crm/archive/2006/07/03/655714.aspx

//CRM standard Dialog: Betreff Subject Entity
go: Einstellungen>Unternehmensmanagement>betreff hinzufügen

//Paymo - CRM export import

1. create client, create project in Primo..
2. Create a Backup (duration 1 day)
3. Download the backup, extract, and format the xml data using "xml beautifier"
4. Add additional clients or projects to the backup xml using visual studio editor.
5. Attempt an upload, clients and projects should be uploaded
==>In CRM map the backup xml data to the desired fields in a specific entity.

Friday, February 21, 2014

Convert Newline Characters in a string into HTML

string path = @"C:\txtFile.txt";
            string rawText = System.IO.File.ReadAllText(path);
            string body = Regex.Replace(rawText, @"(?:\r\n *){1,2} *", "<br />");
            
OR:-
string[] lines = rawText.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None); // alternative replace \r\n with <br />
StringBuilder body = new StringBuilder();
foreach (string line in lines)
 {
   body.AppendLine(String.Format("{0}{1}", line, "<br />"));
     }
            

Friday, November 16, 2012

C# Plugin for Dynamics CRM 2011 How to : from create to install



Too to use: 

CRM plugin Registry tool 2011

steps: 

1. visual studio 2010 
New > Project > Class library > "Name your plugin"
2. Add References (Verweise) : microsoft.xrm.sdk from your sdk installed location
Ready now !

3. Name your class like : public class XYZ : IPlugin 
4. Start with the following code to have the talk with your CRM. The function Execute is your starting point. 
public void Execute(IServiceProvider serviceProvider)
{
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
if (!context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity) return;
Entity entity = (Entity)context.InputParameters["Target"];
// if (entity.LogicalName != "account") return;

try
{
#region init
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
this.service = serviceFactory.CreateOrganizationService(context.UserId);
Entity oEntity = context.PostEntityImages["img"];
#endregion
}
}

-Every edit in the code requires update in the Plugin Reg too

-Prior to Every debug needs to attach (anhängen) the exe file from Debug>process attach  
5. What is oEntity ? This is an image for your post entries to a textfield (for example). The edits you do after the entity loads.

Only the fields those being affected are considered, therefore the changes are recorded as an image. You need to register this image as well as the events (for ex. update and create of an entity) along with the project's successful build file.
For details: http://msdn.microsoft.com/en-us/library/gg309580.aspx
Connect CRM : http://crm234

a. Register a Plug-in Assembly

b.Location example : C:\Program Files\Microsoft Dynamics CRM\Server\bin\assembly\ ...dll or (pdb)

c. Register the Plug-in for an Event

d. we set the plugin as asynchronous. Which means the plugin actions won't effect on priority saving; so that it won't make the system slow.

6. To debug (Erstellen) add a file named copy.cmd inside \bin\debug and type like: 

xcopy "XYZ.dll" "C:\Program Files\Microsoft Dynamics CRM\Server\bin\assembly" /y /v
xcopy "XYZ.pdb" "C:\Program Files\Microsoft Dynamics CRM\Server\bin\assembly" /y /v

-- Right click prject>properties>Buildereignis>type : copy.cmd in the region : Befehlszeile für Postbuildereignis

--Here the successful builds (.dll) and the project file (.pdb) will be overwritten

      --CRM server gonna use this .dll file for the targeted execution.

7. Signature (Signiung): Must be set default which is user specific.
Install plugin to CRM
*********************
Remember where you kept your XYZ.dll file

1. Go to solution > Plugin Assemblys > Add Existing Elements> Add XYZ.dll file to the solution

2. click>SDK message>Add your Registered events (create,update)

Friday, November 9, 2012

Microsoft Dynamics CRM 2011 : At a glance - What can it do?

I was looking for some basic and important information on MSCRM 2011, hope the link below is one of them: 
 http://www.dynamicsexchange.com/CRM-2011/CRM-Overview.aspx#CRMvideos

C# : Read pdf intearactive form text fields, Write those fields values in CSV and XML format

Create a pdf interactive form using adobeFormsCentral>save it>add it in your project.
-- Download iTextSharp >unzip it>find core iTextSharp.dll>add it as reference in your project >finally include this library for your functions> there you are .. ready..

public string pdfInputFile = "//~Files/pdfTest2.pdf"; 
public string pn, nam, ph;

    private void ReadPDF()
    {
        PdfReader pdfRdr = new PdfReader(pdfInputFile);
        AcroFields frm = pdfRdr.AcroFields;
        var fkeys = frm.Fields.Keys;

        pn = frm.GetField("txtID");
        nam = frm.GetField("txtName");
        ph = frm.GetField("txtPhone");
    }


// Write and save an CSV file from the pdf fields values

    private void WriteCSV()
    {
        StreamWriter swFromFile = new StreamWriter(@"c:\temp\temp.csv");
        swFromFile.WriteLine("\"ID\";\"Name\";\"Phone\"");
        swFromFile.WriteLine("\"" + pn + "\";\"" + nam + "\";\"" + ph + "\"");
        swFromFile.Flush();
        swFromFile.Close();
    }


// Write and save an XML file from the pdf fields values

    private void WriteXML()
    {

        XmlWriterSettings settings = new XmlWriterSettings();
        settings.Indent = true;
        try
        {
            XmlDocument doc1 = new XmlDocument();
            doc1.LoadXml("<root><ID></ID><Name></Name><Phone></Phone></root>");

            XmlNode xID = doc1.SelectSingleNode("/root/ID");
            xID.InnerText = pn;
            XmlNode xNam = doc1.SelectSingleNode("/root/Name");
            xNam.InnerText = nam;

            XmlNode xPh = doc1.SelectSingleNode("/root/Phone");
            xPh.InnerText = ph;

            doc1.Save(@"c:\temp\temp.xml");

           }
        catch (Exception ex)
        {
            lblmsg.Text = ex.Message;
        }
        txtFileName.Text = "xml writen from pdf";

    }

Friday, July 27, 2012

Creating an exe/Setup for Asp.net Project

Create Setup Project
  1. Go to file menu > click Add > new project >now “Add New Project” dialog will appear.
  2. Select the “Other Project Types” and click “Setup and Deployment” projects,Choose “Setup Project” give name project name in name text box finally click OK.
  3. New project appear in solution explorer,for eg., you have give the name “MyEXE” file will be displays with given name.
  4. Right click the MyEXE > go View > click “File System”
  5. You can see the “File System on TargetMachine”under three folders Application Folder User’s Desktop User’s Program Menu
  6. Select Application Folder and right click Add>Project Output>select Primary output
  7. Select User’s Desktop right click on the right side pane>click create new shortcut>select output file from Application folder>change the file name from primary output name to MyEXE Same procedure follows the user’s program menu also
  8. If you want to change the Manufactures name, just right click the project go to properties
  9. Finally Build the new project After successfully Build the project myEXE(Setup) will be appear in Application Debug or Release folder(depend upon the properties settings) EXE or installer will be available on his physical path…

Saturday, July 7, 2012

This is the test of the blog posting. Will be coming soon...