Updating User Info

18 views
Skip to first unread message

Nader Chmait

unread,
Jan 13, 2017, 10:26:00 AM1/13/17
to SmartAPI
Hi, 

I was able to create a new user using SmartAPI and now I want to edit the information; for example, changing the username.  I don't know how best to go about it.  I tried using the Commit() function, but it kept throwing an error saying object reference not set to an instance of an object.  Please let me know what the best way to update a user would be.

Thanks!

Jonas Jacobi

unread,
Jan 13, 2017, 11:20:12 AM1/13/17
to smar...@googlegroups.com

Hi,

 

it would be helpful, if you could provide the code snippet that triggers the exception and the stacktrace of the exception itself.

In general you should be able to do something like this:

 

var user = session.ServerManager.Users[“myuser”];

user.Name = “youruser”;

user.Commit();

 

Cheers,

Jonas

--
More information about SmartAPI: http://www.smartapi.de
---
Sie erhalten diese Nachricht, weil Sie in Google Groups E-Mails von der Gruppe "SmartAPI" abonniert haben.
Wenn Sie sich von dieser Gruppe abmelden und keine E-Mails mehr von dieser Gruppe erhalten möchten, senden Sie eine E-Mail an smartapi+u...@googlegroups.com.
Wenn Sie in dieser Gruppe einen Beitrag posten möchten, senden Sie eine E-Mail an smar...@googlegroups.com.
Weitere Optionen finden Sie unter https://groups.google.com/d/optout.

Nader Chmait

unread,
Jan 13, 2017, 12:04:57 PM1/13/17
to SmartAPI
Hi,

I've attached the screenshot of my code and of the runtime error.  Like it says in the screenshot, i realized that deadUser.LanguageOfUserInterface.LanguageAbbreviation and deadUser.NavigationType are both null, but they are read-only properties of the Commit() function.  I think they might be causing the problem, but I'm not sure.  Please let me know if you have an idea.

Thanks again!
IMG_20170113_095957.jpg

Jonas Jacobi

unread,
Jan 18, 2017, 3:55:32 AM1/18/17
to SmartAPI

Hi,

I'm sorry for the late answer.

Could you please try to set the LanguageOfUserInterface before the commit, e.g.

deadUser.LanguageOfUserInterface = session.DialogLocales.First()


Cheers

Jonas


Von: smar...@googlegroups.com <smar...@googlegroups.com> im Auftrag von Nader Chmait <nader....@gmail.com>
Gesendet: Freitag, 13. Januar 2017 18:04:56
An: SmartAPI
Betreff: Re: [SmartAPI] Updating User Info
 

Nader Chmait

unread,
Jan 18, 2017, 11:08:42 AM1/18/17
to SmartAPI
Hi Jonas,

Your advice worked!  Thanks a lot for your help.

Nader
Reply all
Reply to author
Forward
0 new messages