Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

creating new user

Posted on by Microsoft Employee

Hello,


I have written the code for creating the new user but after FINDLAST cursor is not going inside.

If i split the code then it is running working fine.

Please suggest me that where I am going wrong.


//START-002
lrecWebUser.RESET;
lrecWebUser.SETCURRENTKEY("E-Mail Address");
//lrecWebUser.SETRANGE("Customer No.",pCustomerNo);
lrecWebUser.SETRANGE("E-Mail Address",pEmail);
IF lrecWebUser.FINDFIRST THEN BEGIN
 blnExistingEmail:=TRUE;
  ERROR(Text50000, lrecWebUser."Customer No.", lrecWebUser.Username);
END ELSE
BEGIN
    lrecWebUser.SETCURRENTKEY(Username);
     //MESSAGE('hi');
    //lrecWebUser.SETRANGE("Customer No.",pCustomerNo);
    IF lrecWebUser.FINDLAST THEN
    BEGIN
      blnExistingEmail:=FALSE;
      lrecWebUser.Username:=INCSTR(lrecWebUser.Username);
      MESSAGE('%1',lrecWebUser.Username);
      lrecWebUser."First Name":='Aditi';
      //ImportWebUserAdmin.IMPORT;
      //funImportWebUserAdmin('VM0T000001');
      lrecWebUser.INSERT(TRUE);
      MESSAGE('hi');
    END //ELSE
      //blnCorrectEmail:=FALSE;
END;
//STOP-002

*This post is locked for comments

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: creating new user

    Before SETCURRENTKEY(Username) clear the email address filter using SETRANGE again on the same field or you can use RESET to clear the filters.

  • Suggested answer
    RockwithNav Profile Picture
    RockwithNav 6,562 on at
    RE: creating new user

    Go Ahed as suggested by Mohana OR else you can Write

    lrecWebUser.RESET;

    lrecWebUser.SETCURRENTKEY(Username);

  • Verified answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,139 Super User 2024 Season 2 on at
    RE: creating new user

    You need to clear the filter on EMail address as you are using the same record variable lrecWebUser.

    use lrecWebUser.SETRANGE("E-Mail Address"); before FINDLAST

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans