Showing results for 
Search instead for 
Do you mean 
Community Home Request Access Read Blogs Share Your Ideas Search Community View My Settings
Reply
Highlighted
Copper Super Contributor
Posts: 20
Registered: ‎10-10-2012

multiple selection using lookup

Trying to do multiple selection of records (contact) using a lookup, is it possible to accomplish/hack in 754 ?

Smiley Happy

Highlighted
Nickel Contributor
Posts: 46
Registered: ‎08-17-2009

Re: multiple selection using lookup

I'm currently working on it for selecting multiple Contacts to an Opportunity.  I've got the additional requirment of limiting the Contacts to those of the Account linked to the Opportunity.  With thanks to Todd Hardin and Nicolas Galler, I've got a semi-working Editable Grid with a Relate Tool.  It will let you multi-select, and correctly adds the Contacts to the Opportunity, but I have not been able to refresh the lookup to restrict the Contacts to the current Account.  The issue that I run into is that I can filter for the 1st Account, but if the user changes the Account on an Opp, or simply navigates to a 2nd Opp with a different Account, the lookup does not refresh.  I belieive that the proper code is in place, but I need to figure out a way to kill the data in the lookup and force it to refresh.  I can tell it's not refreshing because SLXProfiler does not log any SQL when clicking the + sign on the grid a second time.

 

Anyways, to get were I am, add an Editable Grid with a relate tool.  on the form load, do this:

 

Sage.Platform.WebPortal.Services.ClientContextService ccs = PageWorkItem.Services.Get<Sage.Platform.WebPortal.Services.ClientContextService>();

Sage.Entity.Interfaces.IOpportunity opp = (Sage.Entity.Interfaces.IOpportunity)BindingSource.Current;

string

accountId = "";

if

(opp.Account != null){

accountId = (

string)opp.Account.Id;

}

if

(ccs.CurrentContext.ContainsKey("OpportunityAccountId"))

{

ccs.CurrentContext.Remove(

"OpportunityAccountId");

}

ccs.CurrentContext.Add (

"OpportunityAccountId", accountId);

 

On the Relate Tool (not grid) ConditionalWhere, do this:

function() {

var ccs = Sage.Services.getService("ClientContextService");

var accid = ccs.getValue("OpportunityAccountId");

if (accid == null) return "";

if (accid == "") return "";

return "Account.Id eq '" + accid + "'";

}

 

Right now, I'm playing with the java file to see if I can figure out how to reinitialize the lookup, but I've been at it for a week or so...

Highlighted
Nickel Contributor
Posts: 46
Registered: ‎08-17-2009

Re: multiple selection using lookup

I accomplished it by overriding showLookup:

 

                                lup.showLookup = function() {

                                                var sError = 'The lookup cannot be displayed because one or more conditions have not been met.';

                                                var showError = function (msg) {

                                                                var msgService = Sage.Services.getService('WebClientMessageService');

                                                                if (msgService != null && typeof msgService !== 'undefined') {

                                                                                msgService.showClientError(msg);

                                                                }

                                                                else {

                                                                                alert(msg);

                                                                }

                                                }

                                                var oCanShowLookup = this.canShowLookup();

                                                if (typeof oCanShowLookup !== 'object') {

                                                                showError('The call to the function canShowLookup() returned an invalid result.');

                                                                return;

                                                }

                                                if (typeof oCanShowLookup.result === 'boolean' && oCanShowLookup.result) {

                                                                var self = this;

 

                                                                var dHeight = (self.dialogHeight > 0) ? self.dialogHeight : 390;

                                                                var dWidth = (self.dialogWidth > 0) ? self.dialogWidth : 600;

                                                                var digitId = dijit.byId([lup.id, '-Dialog'].join(''));

                                                                if (digitId)

                                                                {

                                                                                digitId.destroy();

                                                                               dijit.byId([lup.id + '-Grid'].join('')).destroy();

                                                                }

 

                var lookupDialog = new dijit.Dialog({

                                                                                title: self.dialogTitle,

                                                                                id: [lup.id, '-Dialog'].join(''),

                                                                                style: ['height:', dHeight, 'px;width:', dWidth, 'px;'].join(''),

                                                                                refreshOnShow: false,

                                                                                _onKey: lup._onKey

                                                                });

                                                                // Calculate the grid height by subtracting the height of the other dialog elements from the dialog height: dheight-125.

                                                                lookupDialog.attr("content", self.dialogContent.apply({ cancelText: self.cancelText, dialogButtonText: self.dialogButtonText, id: self.id, gridHeight: dHeight - 125 }));

 

                                                                //ToDo: Condition Manager needs to be added to the Sage.UI namespace.

                                                                dojo.connect(ConditionManager.prototype, 'addLookupCondition', this.dialogResize);

                                                               

                                                                lookupDialog.show();

                                                                dojo.destroy([self.id, '-Dialog_underlay'].join(''));

                                                                //Position the dialog just below the main header.

                                                                dojo.style([lup.id, '-Dialog'].join(''), 'top', '60px');

                                                                dojo.style([lup.id, '-Dialog'].join(''), 'left', '25%');

 

                                                                lup.initDialog();

                                                }

                                                else {

                                                                if (typeof oCanShowLookup.reason === 'string' && oCanShowLookup.reason.length != 0) {

                                                                                sError = oCanShowLookup.reason;

                                                                }

                                                                showError(sError);

                                                }

                                                };

Highlighted
New Member
Posts: 1
Registered: ‎11-04-2013

Re: multiple selection using lookup

I was also thinking so but i can't do it.