visual studio lightswitch - Set related entity to current user in HTML Client -


i building desk ticketing program in lightswitch, , have been having trouble 1 requested feature. asked build mobile friendly version of app end users submit tickets mobile devices. built app, couple screens, , added code preprocess query limit tickets can see own. works wonderfully. i'm having trouble assigning logged in user submitter on new ticket. i've looked @ multiple guides online, of stop short @ i'm trying do. promising i've found http://social.msdn.microsoft.com/forums/vstudio/en-us/47832659-4ed3-4a8c-9a62-b3ad46c8e8b4/get-logged-in-employee technique, can succesfully display current user on screen.

the challenge is, setting ticket.enduser field currentusername field. i've tried in created method of addeditnewticket screen, , beforeapplychanges method.

i've been bashing head against wall couple days now, has out there ever accomplished this?


update

so, think may have found problem, not sure how around it. in execute code new ticket button, create ticket, , use newticket.setenduser(). function takes enduser entity parameter, retrieve myapp.activedataworkspace.mydatabase.techs_singleordefault(currentusername) returns null. username primary key techs table.

even when use literal string username, still returns null.

found it!

this forum post had answer. http://social.msdn.microsoft.com/forums/vstudio/en-us/dffe99ea-f12f-42e4-be14-7d5d04c2621f/entitytype-dataworkspaceapplicationdatatypessingleordefaultpr-in-javascript

i had wrap call tech or end user in promise object, gave me array tech/end user looking for, had first element of array.

myapp.activedataworkspace.mydatabase.techs_singleordefault(currentusername).execute().then(function (result) {  entity.settech(result.results[0]); }); 

hopefully save frustration trying in future.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -