Hi @jwestermann17
InventoryItem.ImageUrl contains only name of the attached image that should be used as an associated image.
You can get the full url that you can paste as src parameter using ControlHelper.GetAttachedFileUrl.
I’d suggest trying to add a new unbound field in the customization and try to use it inside your notification.
Here’s an example:
using PX.Data;
using PX.Data.BQL;
using PX.Objects.IN;
using PX.SM;
using PX.Web.UI;
using System;
using System.ComponentModel;
using System.Web;
namespace FullImageUrl
{
public sealed class InventoryItemExt : PXCacheExtension<InventoryItem>
{
[PXString]
[DisplayName("Full Image Url")]
public string UsrTIImageUrl { get; set; }
public abstract class usrTIImageUrl : BqlString.Field<usrTIImageUrl> { }
[PXString]
[DisplayName("Test")]
public string UsrTITestString { get { return HttpContext.Current.Request.Url.Host; } }
public abstract class usrTITestString : BqlString.Field<usrTITestString> { }
}
public class InventoryItemMaintExt : PXGraphExtension<InventoryItemMaint>
{
public void _(Events.RowSelecting<InventoryItem> e)
{
if (!(e.Row is InventoryItem row) || string.IsNullOrEmpty(row.ImageUrl)) return;
var fileNoteIds = PXNoteAttribute.GetFileNotes(e.Cache, e.Row);
var fileGraph = PXGraph.CreateInstance<UploadFileMaintenance>();
foreach (Guid fileNoteId in fileNoteIds)
{
var fileInfo = fileGraph.GetFileWithNoData(fileNoteId);
if (fileInfo.FullName != row.ImageUrl && fileInfo.Name != row.ImageUrl)
continue;
var itemExt = row.GetExtension<InventoryItemExt>();
var imageUrl = ControlHelper.GetAttachedFileUrl(null, fileNoteId.ToString());
itemExt.UsrTIImageUrl = imageUrl;
break;
}
}
}
}
You can also add PXTrace.WriteInformation(imageUrl); to check the value set into the new field.
If you need more than one picture added to the Notification or the example above didn’t give you desired result - I’d also suggest looking into programmatically creating the notification:
var accountId = PX.Data.EP.MailAccountManager.DefaultSystemMailAccountID;
var mailTo = "recipient@test.com"; // replace with your way of getting recipient
var mailSubject = "Your subject";
var mailBody = GenerateBody(); // create desired notification in this method
PX.Data.EP.NotificationSenderProvider.Notify(accountId, mailTo, null, null, mailSubject, mailBody);