0

I'm trying to add an hyperlink from a field in a grid in a processing screen pointing to a custom object I made but it seems it doesnt do anything.

When I try to debug and set breakpoints it seems it doesnt even execute the code in my function.

I tried following this : How to create a hyperlink user field And I tried to follow the example 3.4 in T200 (which is basically the same)

Here's my code :

   public PXAction<ARRegister> ViewLettering;
    [PXButton]
    protected virtual void viewLettering()
    {
        ARRegister row = LinesPendingLettering.Current;

        LELettering letPiece = PXSelect<LELettering,
                                    Where<LELettering.letteringCD,
                                        Equal<Required<LELettering.letteringCD>>>>
                                        .Select(this, row.GetExtension<ARRegisterLeExt>().LettrageCD);

        // Create instance of destination graph
        LetteringAR graph = PXGraph.CreateInstance<LetteringAR>();
        graph.Piece.Current = letPiece;

        if (graph.Piece.Current != null)
        {
            throw new PXRedirectRequiredException(graph, true, Constantes.letteringPiece);
        }
        else
        {
            throw new PXException(Constantes.errNotFound);
        }
    }
    #endregion

And the code of my page :

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

<asp:Content ID="cont1" ContentPlaceHolderID="phDS" Runat="Server">
  <px:PXDataSource ID="ds" runat="server" Visible="True" Width="100%"
        TypeName="LE.ProcessAR"
        PrimaryView="Filter"
        >
    <CallbackCommands>
      <px:PXDSCallbackCommand Name="ViewLettering" Visible="False" DependOnGrid="grid" /></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%" Height="100px" AllowAutoHide="false">
    <Template>
      <px:PXLayoutRule StartColumn="True" ID="PXLayoutRule1" runat="server" StartRow="False"></px:PXLayoutRule>
      <px:PXSelector CommitChanges="True" runat="server" ID="CstPXSelector2" DataField="BranchID" ></px:PXSelector>
      <px:PXSelector AutoRefresh="True" CommitChanges="True" runat="server" ID="CstPXSelector1" DataField="AccountID" ></px:PXSelector>
      <px:PXLayoutRule runat="server" ID="CstPXLayoutRule5" StartColumn="True" ></px:PXLayoutRule>
      <px:PXNumberEdit runat="server" ID="CstPXNumberEdit3" DataField="TotalCredit" ></px:PXNumberEdit>
      <px:PXNumberEdit runat="server" ID="CstPXNumberEdit4" DataField="TotalDebit" ></px:PXNumberEdit>
      <px:PXLayoutRule runat="server" ID="CstPXLayoutRule6" StartColumn="True" />
      <px:PXCheckBox CommitChanges="True" runat="server" ID="CstPXCheckBox7" DataField="ShowAll" ></px:PXCheckBox></Template>
  </px:PXFormView>
</asp:Content>
<asp:Content ID="cont3" ContentPlaceHolderID="phG" Runat="Server">
  <px:PXGrid SyncPosition="True" AutoAdjustColumns="True" ID="grid" runat="server" DataSourceID="ds" Width="100%" Height="150px" SkinID="Details" AllowAutoHide="false">
    <Levels>
      <px:PXGridLevel DataMember="LinesPendingLettering">
          <Columns>
        <px:PXGridColumn Type="CheckBox" AllowFilter="True" AllowCheckAll="True" CommitChanges="True" DataField="Selected" Width="30" ></px:PXGridColumn>
        <px:PXGridColumn DataField="DocType" Width="70" ></px:PXGridColumn>
        <px:PXGridColumn DataField="RefNbr" Width="70" ></px:PXGridColumn>
        <px:PXGridColumn DataField="DocDesc" Width="200" ></px:PXGridColumn>
        <px:PXGridColumn DataField="CuryOrigDocAmt" Width="100" ></px:PXGridColumn>
        <px:PXGridColumn DataField="CuryID" Width="70" ></px:PXGridColumn>
        <px:PXGridColumn LinkCommand="ViewLettering" DataField="LettrageCD" Width="70" ></px:PXGridColumn></Columns>
      </px:PXGridLevel>
    </Levels>
    <AutoSize Container="Window" Enabled="True" MinHeight="150" ></AutoSize>
    <ActionBar >
    </ActionBar>
  </px:PXGrid>
</asp:Content>
Maxime
  • 818
  • 6
  • 24
  • I wonder if it could be a casing issue, in the C# code file I usually make the event handler method start with uppercase and the PXAction with lower case. Double check casing with this page as I know this tutorial has worked for me in the past: http://blog.zaletskyy.com/how-to-add-redirect-to-grid-in-acumatica – Hugues Beauséjour Mar 07 '18 at 15:18
  • Just tried it, no change. It would be quite odd that the T200 was wrong ? – Maxime Mar 07 '18 at 16:00
  • Another possibility could be a DAC mismatch from PXAction (ARRegister) and the PrimaryView (Filter). You can try to substitute ARRegister in PXAction with the DAC of the filter. – Hugues Beauséjour Mar 07 '18 at 16:05
  • You nailed it. It works ! Would you mind posting your comment as an answer so I can accept it ? – Maxime Mar 07 '18 at 16:30
  • Yep I'll do that. – Hugues Beauséjour Mar 07 '18 at 16:38

2 Answers2

0

The generic type parameter of PXAction has to be the same DAC as the primary view DAC.

The primary view attribute is set on PXDataSource element in the ASPX page:

<px:PXDataSource ID="ds" runat="server" PrimaryView="Filter">

In your graph or graph extension you can locate the primary view DAC:

public PXFilter<DAC> Filter;

Make sure the PXAction declaration is on the same DAC:

public PXAction<DAC> Action;
Hugues Beauséjour
  • 8,067
  • 1
  • 9
  • 22
0

Adding an observation I had to this older thread, hoping it may help someone:

If you have everything setup as recommended but it is still not working, look carefully at your use of OrderBy in the View's delegate, specifically whether you defined an OrderBy<> directly on its PXSelectBase or used an OrderByNew<> later in the delegate logic. Using OrderBy<> worked well, but using OrderByNew<> affected the functionality. Details:

The View:

[PXFilterable()]
public PXSelectOrderBy<DAC, OrderBy<Asc<DAC.field1>>> Records;

The Delegate:

protected virtual IEnumerable records()
{
    PXSelectBase<DAC> cmd = new PXSelectJoinOrderBy<DAC,
        InnerJoin<OtherDAC, On<DAC.field1, Equal<OtherDAC.field1>>>,
        OrderBy<Desc<DAC.field1,
                Desc<DAC.field2>>>>(this);    

    ... 
    some filtering logic 
    ...

    // defining OrderByNew affected DependOnGrid/LinkCommand functionality
    // cmd.OrderByNew<OrderBy<Desc<DAC.field1,
    //                       Desc<DAC.field2>>>>();

    foreach(DAC rec in cmd.Select())
        yield return rec;

}

I am using 2018R1, Build 18.112.0019.

FarmerJohn
  • 367
  • 2
  • 8