Quantcast
Channel: CRM Development 論壇
Viewing all articles
Browse latest Browse all 10280

Get WebResponse by OrganizationServiceProxy

$
0
0

Hi All,

I have an senerio in CRm 2011 online.

i have to run an report then download it in Excel Format and send that excel via mail.

Step 1. Connecting to online crm (Working fine)

static OrganizationServiceProxy _serviceProxy;

 public static void Connect()
        {
            //connect  via organization service
            IServiceManagement<IOrganizationService> orgServiceManagement = ServiceConfigurationFactory.CreateManagement<IOrganizationService>(new Uri("MYOrganization"));
            AuthenticationCredentials authCredentials = new AuthenticationCredentials();
            authCredentials.ClientCredentials.UserName.UserName = MYUSERNAME";
            authCredentials.ClientCredentials.UserName.Password = "MYPASSWORD";
            AuthenticationCredentials tokenCredentials = orgServiceManagement.Authenticate(authCredentials);
            _serviceProxy = new OrganizationServiceProxy(orgServiceManagement, tokenCredentials.SecurityTokenResponse);
        }

Step 2. Call report by code(Not sucessfull)

 public static void CallReport()
        {

            string reporturl = "https://MYORG/crmreports/viewer/viewer.aspx?action=filter&helpID=ReportMain.rdl&id=%7b7BEF86BE-FCC4-E211-8BBA-984BE173B305%7d";

string ReportSession = string.Empty;

string downloadurl= "https://MYORG/Reserved.ReportViewerWebControl.axd?ReportSession="+ReportSession+"&Culture=1033&CultureOverrides=True&UICulture=1033&UICultureOverrides=True&ReportStack=1&ControlID=792b7fe029704325b922aff611680ab8&OpType=Export&FileName=ReportName&ContentDisposition=OnlyHtmlInline&Format=EXCEL";
        }

Is their any way to use OrganizationServiceProxy to calling these reporturl  via code. then get ReportSession

then call downloadurl to get file.


Hope this helps. ----------------------------------------------------------------------- Santosh Bhagat If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful"


Viewing all articles
Browse latest Browse all 10280


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>