CRM 2013 - Plugin to retrieve username -


i have autonumber plug-in invokes when user presses save, i've received requirement append initials of person creating record end of ticket.

for example: 0001-0327-rbs

i have been able guid of user creating record, have no idea how literal value outside of sql. haven't been able figure out how can user name of active user creating record. possible within plug-in?

any appreciated. thanks.

you should iorganizationservice iserviceprovider

var context = (ipluginexecutioncontext)serviceprovider.getservice(typeof(ipluginexecutioncontext)); var servicefactory = (iorganizationservicefactory)serviceprovider.getservice(typeof(iorganizationservicefactory)); var service = servicefactory.createorganizationservice(context.userid); 

now can retrieve systemuser using service:

var systemuser = service.retrieve("systemuser", context.userid, new microsoft.xrm.sdk.query.columnset(true)); 

in columnset can specify columns want retrieve (so example "firstname", "lastname", "fullname" etc.).

now can

systemuser["fullname"] 

to name. or if using binds:

systemuser.toentity<systemuser>().fullname 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -