Overview
SalesPad Profile Selector and Script Manager allow users to filter the data returned to a user in grids on the Customer Search, Vendor Search, Inventory Lookup, Sales Document Search, Purchase Order Search, Sales Monitor, and Warehouses, based on custom user-created scripts. Data can be filtered, based on user group, customer class, sales rep, sales territory, etc. This filtering can either be assigned to a Security Group or be manually changed using the Profile Selector.
For example, a data filter script can be created and configured so sales reps can only see their own customers or customers in their own territory. For an example like this, it is important to be thorough and also filter sales documents and any other access point to the customer card, otherwise users would be able to access others’ customers through sales documents for those customers.
Script Manager
Script Manager is comprised of 2 sections: Registration and Scripts. Registration allows users to create profiles and assign users to available security groups. The Scripts section contains all scripts available to be assigned to these profiles/groups.
Follow the steps below to create a script to filter data. The example used in the screenshots below filters data by Sales Person:
- Go to Modules > Script Manager
- On the right side of the window, click New Script and select DataFilterScript
- The new DataFilterScript will appear in the grid below. Enter a script name (Ex. SalesPerson)
- With the new script selected, click Edit. The Script Editor window will appear:
- Enter the script in the white area (you can use one of the sample scripts at the end of this document). Note: Changes or additions made in the gray area will not be saved.
- Click Compile and then OK to save
Next, create a new Script Registration on the left side of the screen:
- Click New Registration. A new field row will appear
- Under Profile Name, select the security group to apply the filter to, or free type in the field to create a registration not connected to a security group
- Select DataFilterScript under Script Type
- Select from the available scripts, or enter the Script Name (must match the script name on the right) and any Script Parameters your custom script needs
- When complete, click Save
Profile Selector
The Profile Selector allows users to switch back and forth between profiles, allowing different data to be filtered. The Profile Selector allows users to run any of the filters regardless of their security group.
After creating the script in the Script Manager:
- Go to Modules > Profile Selector
- A small window will appear. Select the Profile you wish to use and click Apply
- Log out and back in. Your data will now be filtered based on the script entered
The following script filters for Customer Search, Sales Doc Search, and Sales Line Item, by Sales Person ID:
//Filter Customer Search, Sales Documents and Line Items by Sales Person ID// string filterStr = "IAN%";
if (businessObjectName == "CustomerSearch")
{
sc = sc.And(new SearchClause("Sales_Person_ID", SearchOp.Like, filterStr));
}
else if (businessObjectName == "SalesDocumentSearch")
{
sc = sc.And(new SearchClause("Sales_Person_ID", SearchOp.Like, filterStr));
}
else if (businessObjectName == "SalesLineItemSearch")
{
sc = sc.And(new SearchClause("Sales_Person_ID", SearchOp.Like, filterStr));
}
Example Scripts
The following script filters for Customer Search, Sales Doc Search, Sales Line Item, and Sales Monitor, by Sales Person ID:
//Filter Customer Search, Sales Documents, Line Items and Sales Monitor by Sales Person ID//
string filterStr = "Paul%";
if (businessObjectName == "CustomerSearch")
{
sc = sc.And(new SearchClause("Sales_Person_ID", SearchOp.Like, filterStr));
}
else if (businessObjectName == "SalesDocumentSearch")
{
sc = sc.And(new SearchClause("Sales_Person_ID", SearchOp.Like, filterStr));
}
else if (businessObjectName == "SalesLineItemSearch")
{
sc = sc.And(new SearchClause("Sales_Person_ID", SearchOp.Like, filterStr));
}
else if (businessObjectName == "SalesMonitor")
{
bool alreadyExists = false;
foreach (System.SearchParameter sp in sc.AdditionalParameters)
{
if ((sc.AdditionalParameters[0] as System.SearchParameter).ParameterName == "@Sales_Person_ID")
{
alreadyExists = true; break;
}
}
if (!alreadyExists)
sc.AdditionalParameters.Add(new SearchParameter("@Sales_Person_ID", "Paul W."));
}
Customer Search:
if(businessObjectName == "CustomerSearch")
{
sc.And(SalesPad.Bus.Customer._Customer_Class, SearchOp.Equals, "USA-INMI-T2");
}
Inventory:
if (businessObjectName == "InventorySearch")
{
sc.And(new SearchClause("Item_Number", SearchOp.Like, "01"));
}
Sales Rep:
string salesRep = "('SHARON LOLLIES', 'KENNY GAUVREAU')";
if(businessObjectName == "CustomerSearch")
{
salesRep);
}
sc.And(SalesPad.Bus.Customer._Sales_Person_ID, SearchOp.In ,
else if (businessObjectName == "SalesDocumentSearch")
{
salesRep));
}
sc.And(new SearchClause("Sales_Person_ID", SearchOp.In,
else if (businessObjectName == "SalesMonitor")
{
bool alreadyExists = false;
foreach (System.SearchParameter sp in sc.AdditionalParameters)
{
if ((sc.AdditionalParameters[0] as System.SearchParameter).ParameterName == "@Sales_Person_ID")
{
alreadyExists = true; break;
}
}
if (!alreadyExists)
sc.AdditionalParameters.Add(new SearchParameter("@Sales_Person_ID", "(SHARON LOLLIES','KENNY GAUVREA)"));
}
Warehouse:
string wareHouse = "('UTAH FFC','PB FFC')"; if (businessObjectName == "InventoryByLoc")
{
sc.And("Location", SearchOp.In, wareHouse );
}
else if (businessObjectName == "Location")
{
sc.And("Location", SearchOp.In, wareHouse);
}
The following is a list of the most common business objects used with data filter scripts, but there are many more available. Please contact your sales rep for more information.
- CustomerClass
- CustomerSearch
- InventoryByLoc
- InventorySearch
- ItemClass
- Location
- SalesDocument
- SalesDocuments
- SalesDocumentSearch
- SalesMonitor
- SalesMonitorSummary
- SalesRep
- SystemUser
NOTES:
These scripts are considered "as is" and any changes/modifications that might be needed would require a signed quote. Install the scripts for each security group as needed. Make sure that you and all users affected log out and back in for changes to take effect. Scripts should be installed on and run against a test company prior to installing in a live environment.
Security and Settings
Security
Profile Selector - Allows the user to change the profile that is being used to filter the data.
Script Manager - Allows the user to access the Script Manager.
Settings
Data Filter Scripts Enabled - Allows data to be filtered by a Data Filter Script.
SalesPad Support
Comments