08-11-2014 04:29 AM
Hi all,
I am struggling with adding a set of common tasks onto a custom main entity in SLX web 7.5.4. I have followed the guidance in Kris Halsrud's blog here:
I have also added some additional tasks and entries to the same common functions via the details page section. When I run the tasks via the detail page using IEntityHistoryService to get the current entity everything works perfectly, however when I try to invoke the GetSelectionContext method via the list tasks everything blows up with an Object Not Set To An Instance error.
This is the javascript I have in the ascx file:
function FXGetSelections(){
var selectionInfo = GetSelectionInfo();
document.getElementById(clientID + '_hfSelections').value = selectionInfo.key;
var svc = Sage.Services.getService('SelectionContextService');
svc.setSelectionContext(selectionInfo.key, selectionInfo, false);
And this is the corresponding sever-side method that is called by the items_ItemCommand event:
GroupContextService groupContextService = ApplicationContext.Current.Services.Get<IGroupContextService>() as GroupContextService;
CachedGroup currentGroup = groupContextService.GetGroupContext().CurrentGroupInfo.CurrentGroup;
GroupInfo gInfo = currentGroup.GroupInformation;
ISelectionService srv = SelectionServiceRequest.GetSelectionService();
ISelectionContext selectionContext = srv.GetSelectionContext(hfSelections.Value.ToString());
IList<string> selections = selectionContext.GetSelectedIds();
The code always stops when defining the selectionContext object. Any suggestions greatly appreciated as I have been tearing my hair out with this for 3 days now... what am I missing?
08-14-2014 09:04 AM
I had the same problem, and I think it has to do with clientid being null in your clientside script and conseuqnetly passing a null object to the server-side code,
try this:
function FXGetSelections(){
var clientId = "<%= ClientID %>" + "_hfSelections"
var selectionInfo = GetSelectionInfo();
document.getElementById(clientId).value = selectionInfo.key;
var svc = Sage.Services.getService('SelectionContextService');
svc.setSelectionContext(selectionInfo.key, selectionInfo, FXGetSelections);
}
08-15-2014 01:08 AM
Yep, that worked a treat. Does anyone know where the API developer documentation is located now? The Architect helpfile points to a page on the Sage site that isn't live any longer.
Many thanks
Owen