Acumatica销售订单行缩略图问题:选InventoryID后图片不显示
Hey there! Let's figure out why that thumbnail isn't showing up when you select an InventoryID on your sales order line. I'll walk through the key fixes and checks you need to make:
1. Fix Your DAC Extension First
Right now, your ThumbnailURL field is just an empty string property—there's no logic to pull the actual image data from the InventoryItem record, and it's missing critical UI attributes. Here's an updated version that either pulls the image URL directly via a scalar query or sets up the field to accept populated values:
namespace PX.Objects.IN { public class InventoryItemExt : PXCacheExtension<InventoryItem> { #region ThumbnailURL public abstract class thumbnailURL : IBqlField { } [PXString] [PXUIField(DisplayName = "Item Thumbnail")] // Use a scalar query to pull the image reference directly from the InventoryItem's image field [PXDBScalar(typeof(Search<InventoryItem.image, Where<InventoryItem.inventoryID, Equal<Current<InventoryItem.inventoryID>>>>))] public string ThumbnailURL { get; set; } #endregion } }
If the scalar query doesn't work (since Image is a binary field), you'll need to generate a proper temporary URL in a graph event instead—more on that below.
2. Configure the Grid Column in Your ASPX
You need to tell the Acumatica grid to render this field as an image, not plain text. Open your sales order screen's ASPX and add (or modify) the grid column for the thumbnail:
<px:PXGridColumn DataField="InventoryItemExt.ThumbnailURL" Type="Image" Width="120" DisplayName="Thumbnail" />
Make sure the DataField matches your extension field exactly, and set Type="Image" to trigger the image rendering.
3. Add Logic to Populate the Thumbnail URL
If the scalar query approach doesn't pull the image correctly (because InventoryItem.Image stores binary data, not a URL), you'll need to generate a temporary image URL using Acumatica's helper methods. Add this graph extension to your SOOrderEntry:
namespace PX.Objects.SO { public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry> { protected void SOLine_RowSelected(PXCache cache, PXRowSelectedEventArgs e) { SOLine line = e.Row as SOLine; if (line?.InventoryID == null) return; // Fetch the related InventoryItem record InventoryItem item = PXSelect<InventoryItem, Where<InventoryItem.inventoryID, Equal<Required<InventoryItem.inventoryID>>>> .Select(Base, line.InventoryID); if (item?.Image != null) { // Get the extension field and populate it with a thumbnail URL InventoryItemExt itemExt = item.GetExtension<InventoryItemExt>(); itemExt.ThumbnailURL = PXImageUrlHelper.GetUrl( Base, item.Image, PXImageUrlHelper.ThumbnailSize.Small ); } } } }
4. Quick Checks to Rule Out Simple Issues
- Verify InventoryItem has an image: Make sure the selected InventoryID actually has an image uploaded in the Inventory Item screen.
- Check permissions: Ensure your user role has access to the
InventoryItem.Imagefield and temporary file storage (Acumatica uses temp URLs for images). - Clear cache: After making code/ASPX changes, clear the Acumatica cache and restart the application pool to ensure changes take effect.
That should get your thumbnails showing up when you select an InventoryID on the sales order line!
内容的提问来源于stack exchange,提问作者Dane

