0
votes

Hopefully this will be an easy question!

I've created a new report for the Acumatica Opportunity screen, and I'd like to add it to the screen itself. I've previously added a new report to the existing REPORTS dropdown, but I have not played with Automation Steps enough to create the REPORTS dropdown if it does not already exist.

Can someone provide instructions or point me in the direction of the appropriate documentation?

EDIT: So, what I'm running into is that the Opportunity doesn't have a Reports section already there to add to; I have to create it.

What I have so far gets a REPORTS button on the screen but it's not a dropdown and it doesn't appear to do anything.

public class OpportunityMaint_Extension : PXGraphExtension<OpportunityMaint>
{
    #region Event Handlers

    #endregion

    #region Actions

    public PXAction<CROpportunity> report;
    [PXUIField(DisplayName = "Reports", MapEnableRights = PXCacheRights.Select)]
    [PXButton(SpecialType = PXSpecialButtonType.Report)]
    protected virtual IEnumerable Report(PXAdapter adapter,
        [PXString(8, InputMask = "CC.CC.CC.CC")]
        [PXStringList(new string[] { "IOCR6410" }, new string[] { "Quote" })]
        string reportID)
    {
        List<CROpportunity> list = adapter.Get<CROpportunity>().ToList();
        if (!String.IsNullOrEmpty(reportID))
        {
            Base.Save.Press();
            int i = 0;
            Dictionary<string, string> parameters = new Dictionary<string, string>();

            foreach (CROpportunity opp in list)
            {                   
                if (reportID == "IOCR6410")
                {
                    parameters["CROpportunity.OpportunityID" + i.ToString()] = opp.OpportunityID;                      
                }
                i++;
            }
            if (i > 0)
            {
                throw new PXReportRequiredException(parameters, reportID, string.Format("Report {0}", reportID));                  
            }
        }
        return list;
    }

    #endregion
}
1

1 Answers

1
votes

For this type of changes, it's better to not make changes in automation step(s), but follow the approach suggested in How to add report to Inventory Transfers dropdown menu for reports

Below is a slightly updated version of your code snippet, which should lead to the following result:

enter image description here

public class OpportunityMaint_Extension : PXGraphExtension<OpportunityMaint>
{
    public override void Initialize()
    {
        Report.AddMenuAction(QuoteReport);
        Report.MenuAutoOpen = true;
    }

    public PXAction<CROpportunity> Report;
    [PXButton]
    [PXUIField(DisplayName = "Reports", MapEnableRights = PXCacheRights.Select)]
    protected void report()
    { }

    public PXAction<CROpportunity> QuoteReport;
    [PXButton]
    [PXUIField(DisplayName = "Quote", MapEnableRights = PXCacheRights.Select)]
    protected IEnumerable quoteReport(PXAdapter adapter)
    {
        var reportID = "IOCR6410";
        List<CROpportunity> list = adapter.Get<CROpportunity>().ToList();
        Base.Save.Press();
        int i = 0;
        Dictionary<string, string> parameters = new Dictionary<string, string>();

        foreach (CROpportunity opp in list)
        {
            parameters["CROpportunity.OpportunityID" + i.ToString()] = opp.OpportunityID;
            i++;
        }
        if (i > 0)
        {
            throw new PXReportRequiredException(parameters, reportID, string.Format("Report {0}", reportID));
        }
        return list;
    }
}