10-22-2013 06:05 AM
have a question. Hopefully someone can give me an answer or point me to existing code examples on how to solve this.
I'm creating a User lookup from javascript like this:
var lookupConfig = { structure: [ { cells: [ { name: nlsResources.txtName, field: 'UserInfo.UserName', sortable: true, width: "400px", editable: false, propertyType: "System.String", excludeFromFilters: false, defaultValue: "" } ] } ], gridOptions: { contextualCondition: function () { return 'Type ne 5 and Type ne 8 and Type ne 6'; }, contextualShow: '', selectionMode: 'single' }, storeOptions: { resourceKind: 'users', include: ['UserInfo'], sort: [{ attribute: 'UserInfo.UserName' }] }, isModal: true, preFilters: [], returnPrimaryKey: true, dialogTitle: nlsResources.txtSelectUser, dialogButtonText: nlsResources.txtOK }; this.lkpUser = new Lookup({ id: 'lkpUser', readonly: false, config: lookupConfig }); //dojo.connect(this.lkpUser, 'onChange', this, '_userChanged'); dojo.place(this.lkpUser.domNode, this.contentPaneLkpUser.domNode, 'only');
Now, lets say I have a userId 'UXXXXXXXXXXX', and I would like this lookup to be prepopulated with that user as the default selected object when it is created. Is there a way to do that?
Thanks for your help,
Nico.
10-22-2013 08:52 AM
I'm looking into how to write widgets, too, and I'd like to find out if anyone knows where to find documentation on how to pull data from the database.
However, one thing you can do is to look at the Today's Activities widget. It has code to pull in Activities based on the current user's ID. This comes in the html section with code like:
var _currentUserId = Sage.Utility.getClientContextByKey('userID') || '';
_currentUserId = _currentUserId.trim();
(The trim is because this value comes back padded with at least one space in some instances.)
I need more information to use this further, but if you are looking to get the current user, then I think this code will give it to you.