Login / Register  search  syndication  about

          Kris Halsrud's Blog

Kris Halsrud on development and Integration with CRM and Development

Restricting the SalesLogix LiveGrid- Restricting Sales Order Add Products for Available products

 The Livegrid control introduced in SalesLogix 7.5.4 offers a more robust feature set than the SalesLogix datagrid.  Working with the grid is largely manipulating client side code that is all compiled and rendered with the grid at runtime.  There is very little in the way of server side coding that occurs for the LiveGrid.

Today I want to show how to restrict the Sales Order's Products tab to not allow users to select products with a status other than "Available". 

Lets take a look. In the Application Architect, within the Project Explorer, browse to Entity Model...Packages...SalesLogix Application Entities...Sales Order...Forms.

Open up the Quickform SalesorderProducts.

 

Like I said, not a lot to the interface.  Only the grid component. There are Toolbar buttons, but the Add product button is not one of them.  This is because the Add button is actually rendered as part of the grid control to the Toolbar workspace.

Lets take a look at the grid's properties.  Press F$ to open the property window, if it is not open.  Then click the "Editable Grid - Limited" component on the Quickform.

 

You can see in the properties several java script code snippets on the properties like Read only Condition, Conditional Where, On Data Change, etc.  For our part we want to focus on the Tools property. Go ahead and click in the Tools property where it says (Collection).  When the ellipse appears click it.

 

Here you can see the definition of the Tools that will be rendered with the grid.  These are rendered to the screen as buttons on the Toolbar.  The one we want to look at is the "Relate" Tool.  Click the Relate item on the left side of the dialog. On the right side, expand out the Plus sign next to Lookup Properties.

 

The property that controls what is available in the lookup control is the Conditional Where property. In the Conditional Where property, click the drop down arrow to display the code in a slightly larger window.  For ease of demonstration here is the code:

function () {
                var sCondition = '';
                var showError = function (msg) {
                    var msgService = Sage.Services.getService("WebClientMessageService");
                    if (msgService != null && typeof msgService !== "undefined") {
                        msgService.showClientError(msg);
                    }
                    else {
                        alert(msg);
                    }
                }
                var service = Sage.Services.getService("IntegrationContractService");
                if (service != null && typeof service !== "undefined") {
                    if (service.isIntegrationEnabled) {
                        var bFoundOperatingCompany = false;
                        var bFoundSlxPriceList = false;
                        var clientContextService = Sage.Services.getService("ClientContextService");
                        if (clientContextService != null && typeof clientContextService !== "undefined") {
                            if (clientContextService.containsKey("OperatingCompany")) {
                                var sOperatingCompanyId = clientContextService.getValue("OperatingCompany");
                                bFoundOperatingCompany = (dojo.isString(sOperatingCompanyId) && String(sOperatingCompanyId).length == 12);
                                if (bFoundOperatingCompany) {
                                    sCondition += 'AppId eq "' + sOperatingCompanyId + '"';
                                }
                            }
                            var sError = "";
                            if (!bFoundOperatingCompany) {
                                sError = "The Operating Company could not be determined.";
                                showError(sError);
                                throw new Error(sError);
                            }
                        }
                        else {
                            sError = "The ClientContextService is unavailable.";
                            showError(sError);
                            throw new Error(sError);
                        }
                    }
                }
                return sCondition;
            }

You can see this code is returning a  string variable called sCondition.  This variable is essentially an SData condition string that will be used to determine what results are available in the lookup of the products.  Right now you can see OOTB there is a condition applied if the OperatingCompany is defined.  This is part of the Accounting Integration that is embedded in SalesLogix.  The specific line of code that does this is:

sCondition += 'AppId eq "' + sOperatingCompanyId + '"';

We can simply inject a standard condition on top of what is there by default to restrict products to only show "Available"  status products.  To do that we can change the code slightly to be (differences shown highlighted):

 function () {
                var sCondition = 'Status eq "Available" ';
                var showError = function (msg) {
                    var msgService = Sage.Services.getService("WebClientMessageService");
                    if (msgService != null && typeof msgService !== "undefined") {
                        msgService.showClientError(msg);
                    }
                    else {
                        alert(msg);
                    }
                }
                var service = Sage.Services.getService("IntegrationContractService");
                if (service != null && typeof service !== "undefined") {
                    if (service.isIntegrationEnabled) {
                        var bFoundOperatingCompany = false;
                        var bFoundSlxPriceList = false;
                        var clientContextService = Sage.Services.getService("ClientContextService");
                        if (clientContextService != null && typeof clientContextService !== "undefined") {
                            if (clientContextService.containsKey("OperatingCompany")) {
                                var sOperatingCompanyId = clientContextService.getValue("OperatingCompany");
                                bFoundOperatingCompany = (dojo.isString(sOperatingCompanyId) && String(sOperatingCompanyId).length == 12);
                                if (bFoundOperatingCompany) {
                                    sCondition += 'and AppId eq "' + sOperatingCompanyId + '"';
                                }
                            }
                            var sError = "";
                            if (!bFoundOperatingCompany) {
                                sError = "The Operating Company could not be determined.";
                                showError(sError);
                                throw new Error(sError);
                            }
                        }
                        else {
                            sError = "The ClientContextService is unavailable.";
                            showError(sError);
                            throw new Error(sError);
                        }
                    }
                }
                return sCondition;
            }

That is all there is to it. A small change to 2 lines of code.

Once you make this change, click OK on the EditableGridTool Collection Editor.

Then Save the Quickform by pressing the Save icon on the Application Architect's toolbar.

After that you just need to do a  "Build Web Platform" and then Deploy the web site.

jumping into the LiveGrid is a little scary since it is nothing like the older grid.  Coding in the LiveGrid is client based so it is utilizing Java scripting.  It does offer more flexibility though.  in the case of the lookup, you can actually add multiple conditions for restricting results.  Something sorely needed in the standard SalesLogx lookup control.

 

What's This?
  
Bookmark and Share

About Kris Halsrud

   Kris Halsrud is a Senior Analyst / Developer for Customer FX Corporation.


Related Content
   Infor CRM (Formerly Saleslogix) Error in the Web Client- Invalid usage of the option NEXT in the FETCH statement. : Incorrect syntax near 'OFFSET'
 I recently ran into a web client system that was unable to operate properly.  Whenever a page
Posted on Apr 29, 2015 by Kris Halsrud to Kris Halsrud's Blog
 
   InforCRM 8.1 (formerly SalesLogix) SpeedSearch Repair
If the Speedsearch Server is returning an error "Unable to locate the SpeedSearch Directory" a
Posted on Apr 24, 2015 by Mark Duthoy to SalesLogix Support
 
   How do I wrap text in Textboxes in Infor CRM (formerly Saleslogix)?
Recently an Infor CRM administrator contacted me in regards to many of their textboxes for Notes in the I
Posted on Apr 01, 2015 by Dale Richter to Infor CRM Questions & Answers
 
   InforCRM (formerly Saleslogix) Mobile - Clearing Out Earlier Customizations
If you started with an earlier version of SalesLogix Mobile, let's say version 7.5.4, and customized
Posted on Mar 30, 2015 by Mark Duthoy to SalesLogix Support
 
   How do you set the Base Directory when Deploying your Web Client on Infor CRM 8.1?
Question:How do I make sure my Base Directory is set correctly on Infor CRM ? Recently I had a custo
Posted on Mar 06, 2015 by Dale Richter to Infor CRM Questions & Answers
 
Comments

No Comments

Leave a Comment

(required)  
(optional)
(required)  
Add
All contents Copyright © 2015 Customer FX Corporation
Customer FX Corporation
2324 University Avenue West, Suite 115
Saint Paul, Minnesota 55114
Tel: 800.728.5783

  Follow @CustomerFX on twitter
Follow the best news, tips, and articles
  Subscribe to Customer FX on youtube
Watch SalesLogix tutorial videos from Customer FX
Login / Register