Thursday, 29 May 2014

how to access crm record attributes from an opened window

For modeled window

window.showModalDialog(strSourceURL,window,"dialogHeight:600px;dialogWidth:450px;center:yes; resizable:0;maximize:0;minimize:0;status:no;scroll:no");

window.dialogArguments.Xrm.Page.data.entity.attributes.get('crm attribute name').setValue('some value');

---
For non modeled window

window.open(strSourceURL,"customsearchwindow","dialogHeight:600px;dialogWidth:450px;center:yes; resizable:0;maximize:0;minimize:0;status:no;scroll:no");

window.top.opener.Xrm.Page.data.entity.attributes.get('crm attribute name').setValue('some value');

--


Wednesday, 21 May 2014

Creating a custom web.net application that will be hosted in the isv folder

1. Create an empty asp.net website,

2. Add reference to the following assemblies

AntiXssLibrary
Microsoft.Crm
Microsoft.Crm.Platform.Sdk
Microsoft.Crm.Sdk

3. Update web.config enter following details


<?xml version="1.0"?>

<configuration> 

  <system.webServer>

    <validation validateIntegratedModeConfiguration="false"/>

    <modules>

      <remove name="CrmAuthentication"/>

    </modules>

  </system.webServer>

  <system.serviceModel>

    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>

  </system.serviceModel>

  <system.web>

    <compilation debug="true">

      <assemblies>

        <add assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

        <add assembly="System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

        <add assembly="System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

        <add assembly="System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

        <add assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

        <add assembly="System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>

        <add assembly="System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>

        <add assembly="System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

        <add assembly="System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

        <add assembly="System.Web.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>

        <add assembly="System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

        <add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

        <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

        <add assembly="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>

        <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

        <add assembly="System.ServiceModel.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

        <add assembly="System.Data.Services.Client, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

        <add assembly="System.Data.Services.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

        <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>

        <add assembly="System.Web.DynamicData, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

        <add assembly="System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

        <add assembly="System.Web.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

        <add assembly="System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

      </assemblies>

    </compilation>

  </system.web> 
</configuration>

4. To reference fields on the crm entity form use
add a following line in the head tag of aspx/html page

<script type="text/javascript" src="/<crm org name>/webresources/clientglobalcontext.js.aspx"></script>

and then to reference the field on the entity form

<script type="text/javascript">
window.top.opener.Xrm.Page.data.entity.attributes.get("prefix_attributename").setValue("some value")
</script>
 

Monday, 19 May 2014

Reporting Service Error

When trying to open the URL http://<<devbx>>/reportserver  I was getting the error

Reporting Services Error
____________________________________________________________________________

The permissions granted to user 'domain\kaleemkhan' are insufficient for performing this operation.
(rsAccessDenied) Get Online help

____________________________________________________________________________
SQL Server Reporting Services


Resolution:
Open the browser with the option of 'Run as administrator'



---------------------------------------------------------------------------------------------

I created few reports and only one of them was working but others were giving following error

"...The server can not run the report or shared data set. The shared data source 'CRM' for the report server or SharePoint site is not valid.."

Reason:
The reason is when we run the report in CRM it tries to replace the connection string of the crm org i.e. org details ending with _MSCRM with the inline server details but when we use the shared data source report doesn't contains the connection details hence we get error.

Resolutions:

The report is created using the shared data source, and the reason one of the report was working was due to that was the first report and BI studio embedded the connection details with in the report and CRM detected that and update it with the inline crm server and org details.

SQL Reporting Server log path
<program files>\Microsoft SQL Server\MSRS<10_50>.MSSQLSERVER\Reporting Services\LogFiles

replace data in the < > with the relevant details.

Thursday, 8 May 2014

Getting error of mulitpart root elements found when running custom activity to export report as pdf

when running a custom workflow activity which interacts with the sql server and exports the pdf file for it I was getting error message as multipart xml found however the config records had the correct xml. After a bit of investigation I found that the error message was actually coming from the SQLserver so I looked for the SSRS logs at the following location

%ProgramFiles%\Microsoft SQL Server\MSRS<your_version>.mssqlserver\Reporting Services\LogFiles

The error message was about the Data Source I used in the report for CRM wasn't of name DataSource_MSCRM and the report server had a data source of this name.

Resolution:
Update the Data Source name of the report hosted in the CRM to DataSource_MSCRM having embedded data source option selected.

Though the report worked fine from with in the CRM I was getting error from the custom activity so could be the error and resolution is very specific with the custom activity I used.