The SalesLogix web client uses the ext-js library for the SalesLogix groups. Finiding out what records are selected in the group is not that obvious. This post will walk you through what you need to do in order to determine what records are selected.
Determining record selected is really a two step process – the first is a client side call to set a SalesLogix client side library with the records selected, the second part is to actually do something with them. The client side library does expose working with the records selected, but I am going to show you how to use the client side selected records to do something server side.
The first step is to create the client side function to store the selected records. In this example I am going to add a task to the common task area of the task pane. Because of this I will be adding my client side function right to the CommonTasksTasklet.acsx file. In the existing javasript tag of the ascx file I will create the following function:
var selectionInfo = GetSelectionInfo();
document.getElementById(clientID + '_hfSelections').value = selectionInfo.key;
var svc = Sage.Services.getService('SelectionContextService');
svc.setSelectionContext(selectionInfo.key, selectionInfo, false);
This function uses the SelectionContextService and sets the current selections into it.
Now on the ascx.cs file we need to do two things:
- Create a task on the common task area to that can invoke an event after I select my records.
- Wire up the server side code to do something with the selected records.
The first thing I am going to do is add a common task to the Account area. This is done in the FillListViewDictionaries method. If you look the first block of code is defining the account list tasks. I am going to add the line of code shown below in bold. Make note that the tasks are comma delimited so you need to change the existing last task’s line to remove “};” and change it to “,”
string[,] accountListTasks =
Also, make not that the second parameter is a string corresponding to an entry in the ascx resource file. You will need to add an entry corresponding to this in the resource file. I will not go over this here.
As you can see, the third parameter in the line added is a call to my custom client side function. As of right now we have a working page but it will not do anything until we wire up the server side code. To do this we need to look for a method in the cs file called “items_ItemCommand”. In this method is a large case statement that determines which task is clicked based on the task name (parameter 1 in the FillListDictionaries method). Here we will add a new case block of code at the end of the existing code like so:
Here I am invoking a new method called “tskTest_Command”. Lets create that now.
GroupContextService groupContextService = ApplicationContext.Current.Services.Get<IGroupContextService>() as GroupContextService;
CachedGroup currentGroup = groupContextService.GetGroupContext().CurrentGroupInfo.CurrentGroup;
GroupInfo gInfo = currentGroup.GroupInformation;
string passedArgument = hfSelections.Value;
ISelectionService srv = SelectionServiceRequest.GetSelectionService();
ISelectionContext selectionContext = srv.GetSelectionContext(passedArgument);
IList<string> selections = selectionContext.GetSelectedIds();
string msg = "";
foreach (string id in selections)
msg += id + ",";
throw new Sage.Platform.Application.ValidationException(msg);
Here we have server side code working with the SelectionService that we populated client side. In this case I am simply building a list of Ids selected and then displaying that list to the user.
There you have it. A process for getting the client side selections in the SalesLogix group view and working with them server side!