Fri 21 Aug 2009

If you required to set localization / culture in your custom web application that is running in IFRAME section of your CRM Application, according to User preferred language selected by user in Language option, go with the following

 Override the InitializeCulture() method in your custom web application as


        protected override void InitializeCulture()
        {
                base.InitializeCulture();

                WhoAmIRequest whoAmIRequest = new WhoAmIRequest();
                WhoAmIResponse whoAmIResponse = (WhoAmIResponse)crmService.Execute(whoAmIRequest);

                // Get the usersettings entity
                RetrieveUserSettingsSystemUserRequest reqUserSettings = new RetrieveUserSettingsSystemUserRequest();
                reqUserSettings.EntityId = whoAmIResponse.UserId;
                ColumnSet columns = new ColumnSet();
                columns.Attributes = new String[] { "uilanguageid" };
                reqUserSettings.ColumnSet = columns;
                reqUserSettings.ReturnDynamicEntities = true;
                CrmNumberProperty langProp = null;
                int langCode = 0;
                try
                {
                    //Get current logged in user setting
                    RetrieveUserSettingsSystemUserResponse resUserSttings = (RetrieveUserSettingsSystemUserResponse)crmService.Execute(reqUserSettings);
                    DynamicEntity objUserSettings = (DynamicEntity)resUserSttings.BusinessEntity;
                    foreach (Property prop in objUserSettings.Properties)
                    {
                        langProp = (CrmNumberProperty)prop;
                        if (langProp.Name.Equals("uilanguageid"))
                        {
                            //langCode = (CrmNumberProperty)objUserSettings.Properties["uilanguageid"];
                            langCode = langProp.Value.Value;
                            break;
                        }
                    }

                    //Set culture
                    Thread.CurrentThread.CurrentCulture = new CultureInfo(langCode);
                    Thread.CurrentThread.CurrentUICulture = new CultureInfo(langCode);

               }

                catch (System.Web.Services.Protocols.SoapException se)
                {
                    // Log it
                }
        }

If you are looking for Retrieve Cultures information from CRM into your Custom Web Application, have a look at

http://faisalmb.com/blog/post/2009/08/21/CRM-Retrieve-Cultures-information-from-CRM-into-your-Custom-Web-Application.aspx

 

Tags: ,
E-mail this post to someone or Comments here

Add Comment Post comment

 
 
 
   Country flag

Loading

For mobile, tablets or touch devices, if verify button is disabed, please press Enter after entering captcha verfication text than click Verify button.