Skip to main content
Solved

Send attachments of the subcontract through "Email Subcontract" action.

  • September 3, 2021
  • 3 replies
  • 486 views

Hello,

I’m working on a customization where I have to attach subcontract files to Email subcontract action. So end user will get subcontract attachments in the email along with the default report.

At present, acumatica allows only to send report assigned to subcontract in preference will send through email subcontract action. Along with report, I need to attach that particular record file with it.

The action code contains SENDNotificaiton method with the attachment parameter.

But with below code i’m able to send NOTEID of the file to the sendnotificaiton method but I’m unable to see my file in “ALL Email” screen.

Base.Activity.SendNotification(APNotificationSource.Vendor, notificationCD, order.BranchID, parameters, _attachments);

I’m sending NoteID value of the record to this method from my extended graph but the files are not attaching to the email. 

 

I have tried below code:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using PX.Data;
using PX.Objects.AP;
using PX.Objects.CM;
using PX.Objects.CN.CacheExtensions;
using PX.Objects.CN.Common.Extensions;
using PX.Objects.CN.Common.Helpers;
using PX.Objects.CN.Subcontracts.PO.CacheExtensions;
using PX.Objects.CN.Subcontracts.SC.DAC;
using PX.Objects.CN.Subcontracts.SC.Descriptor.Attributes;
using PX.Objects.CN.Subcontracts.SC.Views;
using PX.Objects.Common;
using PX.Objects.Common.Extensions;
using PX.Objects.CR;
using PX.Objects.CS;
using PX.Objects.CT;
using PX.Objects.DR;
using PX.Objects.GL;
using PX.Objects.IN;
using PX.Objects.PM;
using PX.Objects.PO;
using PoMessages = PX.Objects.PO.Messages;
using ScMessages = PX.Objects.CN.Subcontracts.SC.Descriptor.Messages;
using ScInfoMessages = PX.Objects.CN.Subcontracts.SC.Descriptor.InfoMessages;
using PX.Objects;
using PX.Objects.CN.Subcontracts.SC.Graphs;

namespace PX.Objects.CN.Subcontracts.SC.Graphs
{
    public class SubcontractEntry_Extension : PXGraphExtension<SubcontractEntry>
    {
        #region Event Handlers
        //public delegate IEnumerable NotificationDelegate(PXAdapter adapter, String notificationCD);
        //[PXOverride]
        //public IEnumerable Notification(PXAdapter adapter, String notificationCD, NotificationDelegate baseMethod)
        //{

        //  return baseMethod(adapter,notificationCD);
        //}
        private IList<Guid?> _attachments;


        public PXAction<POOrder> notification;

        [PXUIField(DisplayName = "Notifications", Visible = false)]
        [PXButton(ImageKey = PX.Web.UI.Sprite.Main.DataEntryF)]
        protected virtual IEnumerable Notification(PXAdapter adapter,
            [PXString] string notificationCD)
        {
            foreach (POOrder order in adapter.Get<POOrder>())
            {
                Base.Document.Cache.Current = order;
                var parameters = new Dictionary<string, string>();
                parameters["POOrder.OrderType"] = order.OrderType;
                parameters["POOrder.OrderNbr"] = order.OrderNbr;

                using (var ts = new PXTransactionScope())
                {
                    if (Base.Accessinfo.ScreenID == "SC.30.10.00")
                    {
                        _attachments = new List<Guid?>();
                        // _attachments.Add();
                        _attachments.Add(order.NoteID); // sending attachement parameter value here
                        Base.Activity.SendNotification(APNotificationSource.Vendor, notificationCD, order.BranchID, parameters, _attachments);
                    }
                    else
                    {
                        Base.Activity.SendNotification(APNotificationSource.Vendor, notificationCD, order.BranchID, parameters);
                    }
                    Base.Save.Press();

                    ts.Complete();
                }

                yield return order;
            }
        }


        #endregion
    }
}

 

Can anyone guide me to achieve this or any alternate step to send attachments through same action?

Thanks in advance.

 

Best answer by manfredpeukert12

Probably the problem has already been solved. But if you read the guids from NoteDoc, it works.

 var notes =  SelectFrom<NoteDoc>.Where<NoteDoc.noteID.
                        IsEqual<ARRegister.noteID.FromCurrent>>.View.Select(Base);
              
                foreach (NoteDoc note in notes)
                {
                    _attachments.Add(note.FileID);
                }

View original
Did this topic help you find an answer to your question?

3 replies

  • Freshman II
  • 4 replies
  • January 24, 2022

Were you able to find a solution?  I have a customer with a similar request.

Thanks,

Scott


cbashir15
Jr Varsity II
  • Jr Varsity II
  • 10 replies
  • January 25, 2022

@jpavain I think you were able to create a customization to pull attachments into the send email feature.  Can you review the above to see what we may be doing wrong?

 


Probably the problem has already been solved. But if you read the guids from NoteDoc, it works.

 var notes =  SelectFrom<NoteDoc>.Where<NoteDoc.noteID.
                        IsEqual<ARRegister.noteID.FromCurrent>>.View.Select(Base);
              
                foreach (NoteDoc note in notes)
                {
                    _attachments.Add(note.FileID);
                }


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings