Sometimes there is a requirement to encrypt parameter data like passwords, API tokens or other types of secrets. The question is, how is that done in Dynamics 365 Finance and Operations (F&O) without using third party tools?
Well, it's actually straight forward in F&O. You can perform encryption on a table field by using the standard Global::editEncryptedField() method. The base data type of your table field must be of type container. Any other type won't work.
Important
Each F&O environment has it's own encryption key. So, when moving data from the production environment to UAT, Test or Dev, the enrypted data will be obsolete in the new environment. You will have to manually enter the data again in F&O, or export the encrypted data before moving the database, and import the encrypted data after the database movement. The reason for this is because the data was encrypted using the production environments encryption key. The encrypted data cannot be decrypted with the encrpytion key of another environment, only with the encryption key of the environment where it was encrypted.
Steps
1. Add a field of type container to your table. Set the extended data type to EncryptedField.
2. On your table, add an edit method, see code example below.
3. Add a password field to your form and set the data source to your table and data method to your edit method.
Code example
If you want to have a look at an example in the standard application. Have a look at the SysEmailSMTPPassword table and form.
public edit Password editUserPassword(boolean _set, Password _password) { return Global::editEncryptedField(this, value, fieldNum(YourTableName, Password), _set); }
No comments:
Post a Comment