When working on the plugins there are scenarios where the values can be changing from one environment to other like passwords, file paths and so on. In such scenarios it is not advised to hard code these values in the code. Instead we can have this configured in three different ways.
We can add these values as a record into a custom entity. This entity can hold all the values which needs to be configured for the user. The mail advantage of this is the usability when we are migrating the data from one environment to other. Any CRM user can add the values to the system.
But this approach will not help when the solution import happens. Because the data stored is data and not the metadata so when the export and import the solution this will not be included in the solution.
Other approach is that we can use the Configuration field when the plugin is registered. This field will be as a parameter for the plugin execution. This field value can be accessed via the constructor of the plugin class. This can be migrated via the solution import and export.
But the second approach requires the plugin registration tool for changing the values of the configuration. Also if the same plugin has different steps we have to mention the configuration values in all the steps thus making is not that friendly for the user when doing deployment in several systems.
Another approach would be to use a web resource and from the plugin we can read these values. This can be easily moved from one environment to another via the solutions and also the changes to the XML file can be done easily by changing the web resources in single location, if required.
You can refer to the below two sites for a detailed explanation from where I referred/understood these concepts.
Hope this helped you.
No comments:
Post a Comment