Solved

PXAction not showing on custom form


Userlevel 6
Badge +3

I am trying to add an Action to the top of my custom form, but I cannot get it to show.

In the screen editor, it shows the action

My goal is to run a process when the action is clicked.

Here is my graph:

namespace QTCAuditReporting
{
public class QTCAuditReportV3 : PXGraph<QTCAuditReportV3>
{

public PXFilter<QTCAuditHistoryReportFilter> Filter;
public SelectFrom<QTCAuditHistoryReportView>.View RecordsToAdd;
public SelectFrom<QTCAuditHistoryParameters>.View Parameters;

[Serializable]
[PXHidden]
public class QTCAuditHistoryReportFilter : IBqlTable
{

#region ScreenID
[PXString(8, IsFixed = true, InputMask = "")]
[PXDefault]
[PXUIField(DisplayName = "Screen ID", Required = true)]
[PXSelector(typeof(Search5<AUAuditTable.screenID,
InnerJoin<SiteMap, On<SiteMap.screenID, Equal<AUAuditTable.screenID>>>,
Where<AUAuditTable.isActive, Equal<True>>,
Aggregate<GroupBy<AUAuditTable.screenID>>>),
typeof(AUAuditTable.screenID),
typeof(SiteMap.title),
DescriptionField = typeof(SiteMap.title))]
public virtual string ScreenID { get; set; }
public abstract class screenID : PX.Data.BQL.BqlString.Field<screenID> { }
#endregion

#region StartDate
[PXDate]
[PXUIField(DisplayName = "Start Date", Required = true)]
[PXDefault(typeof(AccessInfo.businessDate))]
public virtual DateTime? StartDate { get; set; }
public abstract class startDate : PX.Data.BQL.BqlDateTime.Field<startDate> { }
#endregion

#region EndDate
[PXDate]
[PXUIField(DisplayName = "End Date", Required = true)]
[PXDefault(typeof(AccessInfo.businessDate))]
public virtual DateTime? EndDate { get; set; }
public abstract class endDate : PX.Data.BQL.BqlDateTime.Field<endDate> { }
#endregion

#region AccessHistory
[PXBool]
[PXUIField(DisplayName = "Access History (Override Screen ID)")]
public virtual bool? AccessHistory { get; set; }
public abstract class accessHistory : PX.Data.BQL.BqlBool.Field<accessHistory> { }
#endregion

#region SelectedScreenID
[PXString(8, IsFixed = true, InputMask = "")]
public virtual string SelectedScreenID { get; set; }
public abstract class selectedScreenID : PX.Data.BQL.BqlString.Field<selectedScreenID> { }
#endregion
}

public PXAction<QTCAuditHistoryParameters> GetData;
[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "GET DATA", Enabled = true)]
protected virtual void GetDataSet()
{
QTCAuditHistoryReportFilter filter = Filter.Current;
if (filter != null && (!string.IsNullOrEmpty(filter.ScreenID) || filter.AccessHistory == true) && filter.StartDate != null && filter.EndDate != null)
{
if (filter.AccessHistory == true)
{
Filter.Current.SelectedScreenID = "SM201020";
filter.ScreenID = "SM201020";
}

QTCAuditHistoryParameters auditHistoryParameters = new QTCAuditHistoryParameters
{
ScreenID = Filter.Current.SelectedScreenID,
StartDate = Filter.Current.StartDate,
EndDate = Filter.Current.EndDate.Value.AddDays(1).AddTicks(-1)
};
Parameters.Update(auditHistoryParameters);
this.Actions.PressSave();

GetNewDataset(Filter.Current);

}
}

This is the ASPX

<%@ Page Language="C#" MasterPageFile="~/MasterPages/FormView.master" AutoEventWireup="true" ValidateRequest="false" CodeFile="QT401050.aspx.cs" Inherits="Page_QT401050" Title="Untitled Page" %>
<%@ MasterType VirtualPath="~/MasterPages/FormView.master" %>

<asp:Content ID="cont1" ContentPlaceHolderID="phDS" Runat="Server">
<px:PXDataSource ID="ds" runat="server" Visible="True" Width="100%"
TypeName="QTCAuditReporting.QTCAuditReportV3"
PrimaryView="Filter"
>
<CallbackCommands>
<px:PXDSCallbackCommand Visible="true" CommitChanges="true" Name="GetData">
</px:PXDSCallbackCommand>
</CallbackCommands>
</px:PXDataSource>
</asp:Content>
<asp:Content ID="cont2" ContentPlaceHolderID="phF" Runat="Server">
<px:PXFormView ID="form" runat="server" DataSourceID="ds" DataMember="Filter" Width="100%" AllowAutoHide="false">
<Template>
<px:PXLayoutRule ID="PXLayoutRule1" runat="server" StartRow="True"></px:PXLayoutRule>
<px:PXSelector runat="server" ID="CstPXSelector1" DataField="ScreenID" ></px:PXSelector>
<px:PXLayoutRule runat="server" ID="CstPXLayoutRule2" StartRow="True" ></px:PXLayoutRule>
<px:PXCheckBox runat="server" ID="CstPXCheckBox3" DataField="AccessHistory" ></px:PXCheckBox>
<px:PXLayoutRule runat="server" ID="CstPXLayoutRule4" StartRow="True" ></px:PXLayoutRule>
<px:PXDateTimeEdit runat="server" ID="CstPXDateTimeEdit5" DataField="StartDate" ></px:PXDateTimeEdit>
<px:PXLayoutRule runat="server" ID="CstPXLayoutRule6" StartRow="True" ></px:PXLayoutRule>
<px:PXDateTimeEdit runat="server" ID="CstPXDateTimeEdit7" DataField="EndDate" /></Template>
<AutoSize Container="Window" Enabled="True" MinHeight="200" ></AutoSize>
</px:PXFormView>
</asp:Content>

 

I have tried each of the DACs in the PXAction (QTCAuditHistoryReportFilter, QTCAuditHistoryParameters) but no luck.

I am at a loss.

icon

Best answer by jinin 27 October 2022, 20:26

View original

18 replies

Userlevel 7
Badge +11

Hi @joe21 

In the PXAction, we should use the primary DAC. Can you please change to QTCAuditHistoryReportFilter and try it once?

Like below,

 

public PXAction<QTCAuditHistoryReportFilter> GetData;

Userlevel 5
Badge +1

your Action need the same DAC as the primary view of graph. in this case I think its QTCAuditHistoryReportFilter, if you update your action declaration to use that DAC it should show up

Userlevel 6
Badge +3

I tried that and no joy.

public PXAction<QTCAuditHistoryReportFilter> GetData;

I also tried adding it into the graph declaration, but I get an error.

 

Userlevel 7
Badge +17

@joe21  Tried like below and still no luck?

 

public PXAction<QTCAuditHistoryReportFilter> GetData;

[PXButton(CommitChanges = true)]

[PXUIField(DisplayName = "GET DATA", Enabled = true)]

protected virtual void getData()  → First letter should be a lower case letter

{

           // button logic here

}

Userlevel 5
Badge +1

@Naveen Boga is correct but his post pointed something else out that I missed before. The reason the naming matters is because they are supposed to be the same, e.g. you delegate is should be getData() not getDataSet()

Userlevel 7
Badge +11

Hi @joe21 

The method name also be the same action name, but the first letter should be lowercase

public PXAction<QTCAuditHistoryReportFilter> GetData;

protected virtual void getData()  

{

}

Userlevel 6
Badge +3

@Shawn Burt  I noticed that too.  I did try just changing the first character but that did not work.

I also thought maybe they should match so I tried getData and I get an error.  I think this is why I changed to an upper case.

I recompiled it successfully even with the error, but it still does not show up. 

Userlevel 5
Badge +1

looks like it is expecting an action delegate so should be:

public IEnumerable getData(PXAdapter adapter)

{

       //existing code;

     return adapter.Get();

}

Userlevel 6
Badge +3

I tried following the suggestion in the error message and changed it to 

public PXAction<QTCAuditHistoryReportFilter> GetData;
        [PXButton(CommitChanges = true)]
        [PXUIField(DisplayName = "GET DATA", Enabled = true)]
        protected virtual IEnumerable getData(PXAdapter adapter) 

edit:  this is also added to the code

return adapter.Get();

 

Did not help.  It did get rid of the error message though.

Userlevel 7
Badge +17

 @joe21  try this!

 

public PXAction<QTCAuditHistoryReportFilter> GetData;
        [PXButton]
        [PXUIField(DisplayName = "GET DATA", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select, Enabled = true)]
        protected virtual IEnumerable getData(PXAdapter adapter)
 {

//logic here

return adapter.Get();

}

Userlevel 5
Badge +1

very odd. If willing to share package I am willing to play here to see if I can troubleshoot more for you.

 

Userlevel 6
Badge +3

@Naveen Boga 

That is what my code now looks like.  Still crying.

        public PXAction<QTCAuditHistoryReportFilter> GetData;
        [PXButton(CommitChanges = true)]
        [PXUIField(DisplayName = "GET DATA", Enabled = true)]
        protected virtual IEnumerable getData(PXAdapter adapter)
        {
            //code here

               return adapter.Get();
        }
 

Userlevel 6
Badge +3

@Shawn Burt  How do I get you a copy of the project?  I’d be thrilled if you wanted to look at it.

The only screen to worry about is QT401050.  The other ones are defunct or just trials.

 

Userlevel 7
Badge +17

Hi @joe21  Now, I don’t see any issues with the Action declaration.

Can you please remove the PXHidden for the filter DAC and check once

 

 

Userlevel 6
Badge +3

@Naveen Boga   I removed that and changed it to [PXCacheName("DAC Filter")]

No luck.

Userlevel 7
Badge +11

Hi @joe21 ,

I’ve just created a sample project and I can be able to get the button. I’ve attached the sample package here. Can you please review it once? 

 

Userlevel 6
Badge +3

@jinin  Thank you so much for doing that.  It proved that the code works.  I opened the file and added the mappedrights stuff.  I never used that so I’m sure it is a good thing.

So…..  I just opened the site in Edge and it is there.  It is not showing in Chrome.

Is there something about Chrome causing this?  Perhaps a cached page?  I cleared my cookies and cached images and files but that made no difference.

 

 

Userlevel 6
Badge +3

I just closed Chrome and reopened it.  Strangely, it did not bring back any of my existing tabs I had open.

BUT, the action now shows on the screen. 

Thank you all for your help!  I’m not sure who to flag as the answer for this.  You all provided so many valuable tips.

If one of you would be so kind as to mark one of these as the best answer, I’d be grateful.  :-)

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved