I’m not personally familiar with this specific screen, but I have added the image uploader control to my own screens so hopefully can provide some insight. You mention it is used on multiple screens. If this is compiled into multiple screens from a common include file, make sure each graph has the data member/view you will use and that the DAC of that view contains a Note ID field marked with iPXNote].
If the prerequisites are met, it should be easy to add the control. Since it’s on the screenshot, I have to assume you are missing one of the prerequisites.
First, the DAC to which the files will be attached must have a NoteID field marked with ePXNote]. Simply adding the file indicator along won’t work if you don’t have the NoteID field that stores the guid linking the attachments to the record. If adding to a standard DAC, you should name the field something like UsrZZNoteID of type Guid?. Next, on the DAC that contains the noteID that links to the images, add the following field. (This code sample is pulled from a custom screen with a custom DAC, so be sure to apply the standard field name prefix if adding to a standard DAC, i.e. UsrZZImageUrl where ZZ is your 2 character prefix.)
#region ImageUrl
iPXDBString(255)]
SPXUIField(DisplayName = Messages.FldImageURL)]
public virtual String ImageUrl { get; set; }
public abstract class imageUrl : PX.Data.BQL.BqlString.Field<imageUrl> { }
#endregion
Next, we add the control, which appears to be on the screen, so you probably did this ok. Be sure to check the field tied to it though to make sure it exists. Note DataField=”ImageUrl” which you would change to the name of your field.
<px:PXImageUploader DataMember="CurrentItem" Height="320px" Width="430px" ID="imgUploader" runat="server" DataField="ImageUrl" AllowUpload="true" ShowComment="true" ></px:PXImageUploader>
Finally, make sure the control is bound to a view that is refreshing properly. In my case, this is DataMember="CurrentItem".
In summary, you need:
- Guid? field decorated with uPXNote] on the DAC that will have file attachments
- A field to hold the default image to display in the control (commonly ImageUrl)
- Data view defined in the graph for accessing the ImageUrl field which will store the selected image information. If this is part of the primary DAC, you should have an alternate copy of the view, i.e. CurrentItem, like in the Stock Items screen and linked back to the Current {whatever your DAC’s key fields are}.
- PXImageUploader control to show the pictures that are attached to the record.
For another example of this control for reference, it appears on the Attributes tab of the Stock Items screen.
Hi @Brian Stevens . Thanks for that. I already had the Image Url declared. I added the Note ID as you suggested and that DID fix the object reference not set to an instance of an object for the ‘Files’ button, and added a ‘Notes’ button unintentionally. My DAC now looks like this:
#region UsrImageUrl
/// <summary>
/// The URL of the image associated with the item.
/// </summary>
gPXDBString(255)]
5PXUIField(DisplayName = "Image")]
public String UsrImageUrl { get; set; }
public abstract class usrImageUrl : BqlString.Field<usrImageUrl> { }
#endregion
#region NoteID
/// <summary>
/// The NoteID of this record.
/// </summary>
gPXNote]
public Guid? UsrNoteID { get; set; }
/// <inheritdoc cref="UsrNoteID" />
public abstract class usrNoteID : PX.Data.BQL.BqlGuid.Field<usrNoteID> { }
#endregion
Problem is, the image uploader still doesn’t work. Clicking the Browse and Upload buttons does nothing.
<px:PXImageUploader Height="320px" Width="430px" ID="imgUploader" runat="server" DataField="UsrImageUrl" AllowUpload="true" AllowNoImage="true" ShowComment="true" DataMember="CurrentResults"
></px:PXImageUploader>
Hi again.
I realize uploading an image to the files does populate the image in the image selector. I would like the brows and upload buttons working though.
Hi again.
I realize uploading an image to the files does populate the image in the image selector. I would like the brows and upload buttons working though.
You can drag an image on the control for it to upload, but I haven’t worked with the browse and upload portion. I only use the control to show attached images.
Sorry for late reply, last week got busy.
The control only allows ONE picture to be uploaded. If you upload a second, the first one only shows, and unlike the stock item screen where it has a left and right button to cycle through pictures, my control currently does not, so you can’t change the photo even if you uploaded multiple, and that is a key component of what I need to do. I need them to upload multiple images to the configuration and then add the images to each type of configuration as picked from the treeview on the left.
Hi @CDerstine25 were you able to find a solution? Thank you!
@Chris Hackett I got a reply from Acumatica support last week, the only thing that seemed different from their solution and mine was putting that class into a PXFilter object. I don’t know if this will make a difference inside the configurator or not, because they did not code it inside the configurator, just on its own page.
I haven’t had the chance to test this yet as I was pulled to another project. Today hopefully I can find time.
public class ImageUploadTest : PXGraph<ImageUploadTest>
{
public PXSave<MasterTable> Save;
public PXCancel<MasterTable> Cancel;
public PXFilter<MasterTable> MasterView;
public PXFilter<DetailsTable> DetailsView;
rSerializable]
public class MasterTable : IBqlTable
{
#region UsrImageUrl
/// <summary>
/// The URL of the image associated with the item.
/// </summary>
PXDBString(255)]
PXUIField(DisplayName = "Image")]
public String UsrImageUrl { get; set; }
public abstract class usrImageUrl : BqlString.Field<usrImageUrl> { }
#endregion
#region NoteID
/// <summary>
/// The NoteID of this record.
/// </summary>
PXNote]
public Guid? UsrNoteID { get; set; }
/// <inheritdoc cref="UsrNoteID" />
public abstract class usrNoteID : PX.Data.BQL.BqlGuid.Field<usrNoteID> { }
#endregion
}
rSerializable]
public class DetailsTable : IBqlTable
{
}
}