1

I want to display a GI on one of the tab in any screen.

For example, there is a new custom GI for OrderMargin which I want to display on SO screen on a new tab that will show the Order Margin for a particular order only.

OrderMargin is simple GI with SOOrder, SOLine and InventoryItem table joins and few columns required columns with margin calculations.

Can anyone suggest?

RuslanDev
  • 6,718
  • 1
  • 14
  • 27
Krunal
  • 1,138
  • 1
  • 9
  • 28

1 Answers1

4

Let's say you've created a GI called SalesOrderMargin with 2 hidden parameters: enter image description here

To embed this GI into the Sales Orders page, you should follow the steps below:

  1. Declare new unbound field for SOOrder to return absolute URL for the SalesOrderMargin GI:

    public class SOOrderExt : PXCacheExtension<SOOrder>
    {
        public abstract class marginGiUrl : IBqlField { }
        [PXString]
        [PXUIField(Visible = false)]
        public string MarginGiUrl
        {
            get
            {
                if (string.IsNullOrEmpty(Base.OrderType) || 
                    string.IsNullOrEmpty(Base.OrderNbr)) return string.Empty;
    
                string inqName = "SalesOrderMargin";
                var url = new StringBuilder(PXGenericInqGrph.INQUIRY_URL)
                    .Append("?name=").Append(inqName)
                    .Append("&SOOrderType=").Append(Base.OrderType);
                    .Append("&SOOrderNbr=").Append(Base.OrderNbr);
                    .Append("&hidePageTitle=true");
                return PX.Common.PXUrl.SiteUrlWithPath().TrimEnd('/') + 
                    url.ToString().Remove(0, 1);
            }
        }
    }
    
  2. On the Sales Orders screen, add new tab with a PXSmartPanel container set up to render as an iframe:

    <px:PXTabItem Text="Margins" >
        <Template>
            <px:PXSmartPanel runat="server" ID="panelMarginGI" RenderIFrame="True" 
                AutoSize-Enabled="true" SkinID="Frame" LoadOnDemand="true"/>
        </Template>
    </px:PXTabItem>
    
  3. Place input control for the custom SOOrder unbound field declared in step 1 somewhere in the Sales Orders' top level PXFormView container (input control will always be hidden from the users and is only required to assign source URL for the PXSmartPanel):

    <px:PXFormView ID="form" runat="server" DataSourceID="ds" Width="100%" 
        DataMember="Document" Caption="Order Summary"...>
        <Template>
            ...
            <px:PXTextEdit ID="edMarginGiUrl" runat="server" DataField="MarginGiUrl" />
        </Template>
    </px:PXFormView>
    
  4. In SO301000.aspx insert JavaScript code to assign source URL for the PXSmartPanel:

    <script type="text/javascript" language="javascript">
        function commandResult(ds, context) {
            var commands = ["ReloadPage", "Save", "Cancel", "Insert", "First", "Previous", "Next", "Last"];
            if (commands.indexOf(context.command) >= 0) {
                var marginGiUrl = px_alls["edMarginGiUrl"];
                var smartpanel = px_alls["panelMarginGI"];
                if (marginGiUrl || smartpanel) {
                    var url = marginGiUrl.getValue();
                    smartpanel.setPageUrl(url);
                    smartpanel.repaint();
                }
            }
        }
    </script>
    
  5. Subscribe to the CommandPerformed event of PXDataSource to invoke the commandResult JavaScript function:

    <px:PXDataSource ID="ds" runat="server" Visible="True" Width="100%" TypeName="PX.Objects.SO.SOOrderEntry" PrimaryView="Document">
        <ClientEvents CommandPerformed="commandResult" />
        ...
    </px:PXDataSource>
    

And this is how your SalesOrderMargin GI should appear on the Sales Orders screen: enter image description here

RuslanDev
  • 6,718
  • 1
  • 14
  • 27