0

I need to show image uploaded by users and show this on grid like the picture below:

enter image description here

At first, I use PXImageUploader for this column but it doesn't work. I can't upload image by using Upload button, only drag and drop and some problems with it. I think this way is not good.

Then, I use another way that is uploading images to Files, copy External link from SM202510 and paste to this column. It's OK but users have to perform too much steps to do that, it's kind of complicated for user so I want to find a way to get image link and paste automatically.

The problem is I can't find something like an event FieldUpdated with NoteID to get the image link when user uploaded the image.

Is there any way to do that or do you have a suggestion for me in this situation?

Brendan
  • 5,428
  • 2
  • 17
  • 33
Jade.B
  • 17
  • 3
  • Something similar for reference: https://stackoverflow.com/questions/39926127/how-to-show-images-inside-selector-lookup – Brendan Oct 22 '19 at 13:54

1 Answers1

2

For form container use PXImageView control.

For grid container you can use PXGridColumn element with DisplayMode and Type properties:

<px:PXGridColumn DataField="UsrImage" DisplayMode="Value" Type="Icon" />

Compose External Link URL with the file UID property and assign the URL string to the field displaying the image. I tested this method to show the first image that was attached to the grid record.

public class SOOrderEntry_Extension : PXGraphExtension<SOOrderEntry>
{
    public void SOLine_UsrImage_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
    {
        PX.SM.UploadFileMaintenance upload = PXGraph.CreateInstance<PX.SM.UploadFileMaintenance>();

        foreach (Guid noteId in PXNoteAttribute.GetFileNotes(sender, e.Row))
        {
            PX.SM.FileInfo fileInfo = upload.GetFile(noteId);

            if (fileInfo != null)
            {
                string fileExtension = System.IO.Path.GetExtension(fileInfo.Name).ToLowerInvariant();

                if (fileExtension == ".png" || fileExtension == ".jpg" || fileExtension == ".jpeg" || fileExtension == ".gif")
                {
                    e.ReturnValue = string.Concat(PXUrl.SiteUrlWithPath(), "/Frames/GetFile.ashx?fileID=", fileInfo.UID.ToString());
                    break;
                }
            }
        }
    }
}

enter image description here

Hugues Beauséjour
  • 8,067
  • 1
  • 9
  • 22