NAV 2013 Web Service User Card Create error

nboettchernboettcher Member Posts: 14
edited 2013-06-06 in NAV Three Tier
I am trying to use Web Services in NAV to access the User Card page. I have successfully set up the Web Service and have been able to call it from my application. I can read users, update users and delete users...however, when i try to use the .Create(ref newUser) method I get an error and can't figure out how to create a new user.

Here is the error:

User Name must have a value in User: User Security ID={6A9F7C77-13D6-43CA-A9F9-FDE1498584E7}. It cannot be zero or empty.

It doesn't matter what values I set in the User, including User_Name...I always get this message.

Any advice?

Comments

  • camecame Member Posts: 12
    Hi,

    nice work!
    Can you explain more about your user creation?

    Maybe this helps...
    In NAV page users (9800) you can see that it will create a guid for every new user as User Security ID. This is the primary key ... see table User (2000000120)
    You should do the same.
    In C# you can use
    Guid.NewGuid()
    
    fill this guid with the User Security ID!
    You can get the SID for your user with "DirectorySearcher" or NAV Assembly "Microsoft.Dynamics.Nav.NavUserAccount"

    Came


    *Update*

    Hi,

    so now i have written my own C# Application to check your issue.
    I have the same one.
    Always if I want to create a new NAV User i get your error message.
    But I have a solution!

    When you look at Page 9800 "Users" -Trigger OnInsertRecord :
    IF "User Name" = '' THEN
      ERROR(Text004,FIELDCAPTION("User Name"));
    

    Change the code to:
    IF GUIALLOWED THEN //Checks whether the C/AL code is allowed to show any information on the screen
      IF "User Name" = '' THEN
        ERROR(Text004,FIELDCAPTION("User Name"));
    

    Works great for me.
    This will not effect NAV Standard.

    But my problem is... how validate the input data?
Sign In or Register to comment.