File type columns in Microsoft Dynamics 365 CRM are a useful feature for storing binary data, such as documents, images, or other files directly within a record. However, when it comes to deleting these columns, users may notice something unusual: the system allows deletion without showing dependencies or warnings. This article explains why this happens, the risks involved, and provides best practices for safely managing file type columns.
Understanding File Type Columns in Dynamics 365 CRM
The file type column is a specialized column introduced to handle file storage within records. Unlike other column types, such as lookup fields or option sets, the file column is primarily used to store data and doesn’t inherently establish dependencies in workflows, relationships, or business logic.
This behavior often leads to a scenario where users can delete a file type column without encountering warnings about dependencies, even if it is actively used in forms or custom scripts.
Why Doesn’t the System Warn About Dependencies?
- No Dependency Check for File Columns:
File type columns typically don’t participate in relationships or workflows in the same way as lookup fields or other dependent columns. If the column is not explicitly linked to critical business processes, the dependency checker assumes no usage. - Design Choice for Simplicity:
The system treats file columns as auxiliary data storage. It assumes users have evaluated its usage before deletion, leading to no comprehensive checks during the deletion process.
Example Scenario
Let’s explore an example to understand the implications of deleting a file type column:
- Setup:
You create a file type column named “Contract File” in the Account entity to store signed contracts. The column is added to the Account Main Form for users to upload and view files. - Usage:
- Sales teams upload contract documents directly to the Contract File field in the Account records.
- The column is actively used in custom JavaScript that validates whether a contract has been uploaded before saving the record.
- Deletion:
- A user deletes the “Contract File” column without checking its usage. The system doesn’t show warnings about dependencies because the column is not explicitly tied to workflows, relationships, or plugins.
- A user deletes the “Contract File” column without checking its usage. The system doesn’t show warnings about dependencies because the column is not explicitly tied to workflows, relationships, or plugins.
- Impact:
- All contract files previously uploaded are permanently lost.
- The JavaScript that referenced the column fails, causing errors in form validation.
Risks of Deleting File Type Columns
- Data Loss: Deleting a file column removes all files stored in it.
- Broken Customizations: If the column is referenced in JavaScript, integrations, or external applications, they may stop working after deletion.
- Invisible Dependencies: The lack of dependency checks means users might miss its usage in forms or other areas.
Best Practices for Managing File Type Columns
- Audit Usage Before Deletion:
- Check if the file column is used in forms, views, workflows, JavaScript, or external integrations.
- Remove the column from forms and views first, then monitor its impact.
- Backup Files:
- Export files from the column to a secure location, such as Azure Blob Storage or a local drive, before deleting the column.
- Export files from the column to a secure location, such as Azure Blob Storage or a local drive, before deleting the column.
- Manually Validate Dependencies:
- Since dependency checking for file columns is limited, perform a manual review of the column’s usage across your CRM environment.
- Since dependency checking for file columns is limited, perform a manual review of the column’s usage across your CRM environment.
- Test Before Final Deletion:
- Use a sandbox environment to test the impact of removing the column before making changes in production.
Example Solution: Validating Usage with JavaScript
Here’s an example script to validate if the file column is used in the Account Main Form:
function checkFileFieldExistence() {
var fileField = Xrm.Page.getAttribute("contractfile");
if (!fileField) {
console.warn("The file column 'Contract File' has been deleted or is unavailable.");
} else {
console.log("File column 'Contract File' is available and functional.");
}
}
This script ensures that your customizations, like JavaScript, gracefully handle scenarios where the column is missing.
Conclusion
While file type columns in Dynamics 365 CRM are incredibly useful, their behavior during deletion requires special attention. The lack of dependency warnings can lead to data loss or broken customizations if proper precautions are not taken. By auditing usage, backing up data, and manually checking for dependencies, you can safely manage and delete file type columns in your CRM system.
Have you faced challenges with file type columns in Dynamics 365 CRM? Share your experience or best practices in the comments!