Monday, December 31, 2012

Reading Organization Setting

Problem:
               Need to read organization settings

Solution:
               To read the organization information like what is the maximum size of the file which can be uploaded? , Currency format code and currency symbol (like ($) dollar sign for USA etc), date and time format string for organization level, and fiscal year related information etc, we need to read the organization entity to get these and other organization related attributes.

Image 1

Code for the reading organization is listed in List 1, here you can see that it is simple query expression which read all the columns and no user based condition which I have added while reading the User setting (Where I have used the current user id to get the user settings).
List 1

After the call is send and it return control is shifted to "getEntityRecord_ClickCallback" call back to process the return value from the request. Code is listed in List 2, here you can see that I have used to for each loop on the list which contains the meta data of the organization setting entity. Here I fist check for if the entity contains attribute or not and then check the attribute type whether attribute is pick list or lookup type because to get value of the lookup and pick list is different.If you get the value of the pick list then it will give you integer part of the pick list and we need the string value of the pick list to be displayed. Here you can see that I have get the integer value of the pick list in local variable and then search for the string value of the pick list in the list ( I have also save pick list option set in local list of the record so that I don’t need to make another MS CRM call to get option sets of the particular pick list, you can also see the code of the call back of the meta data request of the organization setting entity for reference).
List 2
This was all how to get the organization setting to get organization setting. You can download source code and CRM 2011 solution for testing and modification from the links which are given below.
Downloads
You can download the source code of the sample from here.
and working CRM 2011 solution from here.


Go to Home

All and any comments / bugs / suggestions are welcomed!

No comments: