Overview
In ACRM/CRM.web, a one-off custom document upload action may still open with the default upload dialog configuration (for example, logs show expandName:"D1.Upload") even when a custom expand/field group exists. This typically happens when expandName is passed to an API that does not support it (u8.services.documents.createDocument(...)) or when expandName is passed at the wrong object level in u8.services.documents.upload(...).
The recommended approach is to use the upload popup flow (u8.services.documents.upload(...)) with a correctly structured options payload: provide a top-level infoAreaId (or uid/documentKey) to satisfy validation, and place expandNameupload:{...} so the DocumentUpload widget applies the custom expand.
Solution
Scenario
You need a one-off custom document upload dialog in ACRM/CRM.web that shows additional fields (for example, two catalog fields) without changing the global/default upload dialog (for example, without modifying D1.Upload or global settings such as D1.Upload.details).
Symptoms / How to Recognize It
- The upload dialog opens, but the additional fields from your custom configuration do not appear.
- CRM.web console/network shows the default expand being used, for example
expandName:"D1.Upload"in theExpandChannel.Getpayload. - If the
documents.upload(...)call is structured incorrectly, you may see this exact exception:Exception: Error:In order to upload a document you must specify a uid, a documentKey or an info area id!; uid=u8.Base/Error/99
Root Cause
-
u8.services.documents.createDocument(...)cannot switch the upload dialog viaexpandName.Passing
expandNametocreateDocumentdoes not change which upload fields are shown, so the UI continues to use the default upload configuration. -
u8.services.documents.upload(...)has two simultaneous requirements.-
Top-level validation requirement: the object passed to
documents.upload(...)must include one of:uid, ordocumentKey, orinfoAreaId
-
Upload widget configuration requirement: the upload popup applies UI options (including
expandName) from a nested object:upload: { ... expandName ... }
-
-
If
expandNameis not insideupload:{...}, the upload UI falls back to the default (commonlyD1.Upload). If everything is placed only underupload:{...}and the top-level options omituid/documentKey/infoAreaId, the call fails immediately with the validation exception shown above.
Resolution (One-Off Upload Button/Action)
1) Prepare the CRM.Designer Configuration
- Create (or confirm) a D1 expand configuration and underlying field group that contains the extra catalog fields you need.
- Use the base expand name for runtime references (do not reference the
.detailssuffix as the runtime name). - Example naming pattern:
D1.<custom_upload_expand_name>
2) Use u8.services.documents.upload(...) with Correct Nesting
Provide a top-level infoAreaId (to satisfy validation) and keep expandName under upload:{...} (so the upload widget applies it):
myNamespace.customDocumentUpload = function (args) {
u8.services.documents.upload({
infoAreaId: "D1",
upload: {
linkUid: { infoAreaId: "<linked_info_area_id>", recordId: args.uid.recordId },
allowMultiple: false,
expandName: "D1.<custom_upload_expand_name>"
}
}, function (sender, result) {
// result.uid = uploaded document uid
});
};
Notes:
- Keep values quoted as strings (unless you intentionally pass variables).
linkUidshould point to the record you want the uploaded document to be linked to (replace<linked_info_area_id>appropriately).
3) Invalidate CRM.web Cache After Configuration Changes
After adding or changing upload-related configuration in CRM.Designer, invalidate the CRM.web cache so clients load the updated configuration. UI configuration changes commonly require cache invalidation before they take effect.
Verification
- Click the one-off upload button/action.
- Check CRM.web network/console for the
ExpandChannel.Getpayload. - Confirm it now uses your custom expand name:
- Expected:
expandName:"D1.<custom_upload_expand_name>" - Not expected:
expandName:"D1.Upload"
- Expected:
- Confirm the upload dialog displays the additional catalog fields and that the document upload completes successfully.
Frequently Asked Questions
- 1. How do I know this is the same issue?
-
This matches if you either (a) see the upload dialog still using the default expand in logs (for example
expandName:"D1.Upload"), or (b) you hit the exact exception:Exception: Error:In order to upload a document you must specify a uid, a documentKey or an info area id!; uid=u8.Base/Error/99 - 2. Why doesn’t
expandNamework withu8.services.documents.createDocument(...)? -
The upload dialog configuration is not switched by passing
expandNameintocreateDocument(...). For a custom upload UI (extra fields/catalogs), use the upload popup flow (u8.services.documents.upload(...)) and passexpandNamein the structure consumed by the upload widget. - 3. I nested everything under
upload:{...}and now I get: “In order to upload a document you must specify a uid, a documentKey or an info area id!” -
Add a top-level
infoAreaId:"D1"(or provide a top-leveluid/documentKey). The upload service validates the top-level object before the popup opens, even though UI options likeexpandNamemust remain underupload:{...}. - 4. How can I verify the custom expand is actually being applied?
-
Inspect the
ExpandChannel.Getrequest payload and look forexpandName. If it shows the default (for exampleD1.Upload), the custom value is not reaching the upload widget. When correctly applied,expandNameshould match your custom value (for exampleD1.<custom_upload_expand_name>). - 5. Do I need to change
Document.UploadFieldGroup.D1for this one-off use case? -
No.
Document.UploadFieldGroup.D1controls the global/default upload dialog. For a single special action, keep the global default unchanged and pass your customexpandNameonly in the one-offdocuments.upload(...)call. - 6. I updated the Expand/Field Group in CRM.Designer but nothing changes in CRM.web. What should I do?
-
Invalidate the CRM.web cache after configuration changes, then reload the client. Configuration updates commonly require cache invalidation before they appear in the UI.
Priyanka Bhotika
Comments