How to create a hyperlink user field

I have a user field that displays ARRegister.RefNbr. This user field is contained in the APTran grid. The user actually creates an AR invoice with a custom action and the new AR document ref nbr is saved in the APTran grid. I want to create a user field as a hyperlink (similar to the Inventory Receipt Reference Number in the SO Delivery Order tab). Should I be using the PXSelector control? What are the proper attributes? The goal is to open the AR invoice screen when the user clicks on the user field.

+3


source to share


2 answers


There is a general approach that allows you to add references to grid cells and is not based on selectors or anything else. To complete it, you need to follow these steps:

1. Define an action on your chart that handles redirects. Something like that:

public PXAction<YourMainDAC> ViewInvoice;

[PXButton]
protected virtual void viewInvoice()
{
    ARTran row = Transactions.Current;
    string docType = //get Doc Type from the tran record
    string refNbr = //get Ref Nbr from the tran record
    ARInvoice invoice = PXSelect<ARInvoice, 
        Where<ARInvoice.docType, Equal<Required<ARInvoice.docType>>,
          And<ARInvoice.refNbr, Equal<Required<ARInvoice.refNbr>>>>>
            .Select(this, row.YourDocTypeField, row.YourRefNbrField);

    // Create the instance of the destination graph
    ARInvoiceEntry graph = PXGraph.CreateInstance<ARInvoiceEntry>();
    graph.Document.Current = invoice;

    // If the invoice is found, throw an exception to open
    // a new window (tab) in the browser
    if (graph.Document.Current != null)
    {
        throw new PXRedirectRequiredException(graph, true, "AR Invoice");
    }
}

      

2. In the .aspx page definition, add a callback command that corresponds to the new action (replace grid

with the grid id ARTran

on your page):

<px:PXDataSource ID="ds" ... >
    <CallbackCommands>
        <px:PXDSCallbackCommand Name="ViewInvoice"
            Visible="False"
            DependOnGrid="grid">
        </px:PXDSCallbackCommand>
    </CallbackCommands>
</px:PXDataSource>

      



3. In the column of the grid where you want to add a link, specify the link command to point to above PXDSCallbackCommand

:

<px:PXGridColumn DataField="InvoiceNbrOrSomething"
                 LinkCommand="ViewInvoice">
</px:PXGridColumn>

      

This is a bit lengthy way to define a link, but firstly, it does not place any restrictions on the field where you add the link, and it also gives you full control over which graph to open and what to show there.

Note: you may also need to set SyncPosition="true"

in the grid control to aspx.

The example is adapted from Example 3.4 in the Acumatica T200 tutorial. You may want to read some detailed explanations and get more information.

+7


source


If you have a selector related to the Acumatica standard table, such as adding a custom field containing a selector against InventoryItem or ARInvoice, you can set AllowEdit = True on your field on the page containing your custom field. This will automatically add a hyperlink. If your field does not contain a selector, it will not work if there is no setting for segments.

We have custom tables that we added to our project where we need hyperlinks. As long as you add the PXPrimaryGraph attribute to the DAC, you should be able to do the same for the full custom page / dac.



We started using LinkCommand, but the AllowEdit approach provides simple code without the need for special logic for the link. More complex logic than going to the first field graph will require a link.

+2


source







All Articles