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

                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;
                    //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;

                    //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


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

Add Comment Post comment

   Country flag


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