• Saving User Profile

    By Andrew Tetlaw 2 decades ago

    If a user wants to edit his/her profile but registrtion is NOT enabled they receive an error and saving is not possible.



    I had a look at the (registration) agent which runs on the user profile webquerysave and indeed that's the way it's coded: a user cannot update their profile if user registration is not enabled:


    'Check if registration is allowed<br/>
    If ctx.IsNewNote And profile.GetItemValue(&quot;AllowRegistration&quot;)(0) &lt;&gt; &quot;YES&quot; Then<br/>
        ErrorCode=&quot;1&quot;<br/>
        Goto ErrorHandler<br/>
    End If <br/>
    

    [snip]



    ErrorHandler:

    If ErrorCode=&quot;&quot; Then ErrorCode=&quot;0&quot;<br/>
    Call ctx.ReplaceItemValue(&quot;ErrorCode&quot; , errorcode)<br/>
    Call ctx.ReplaceItemValue(&quot;SaveOptions&quot; ,&quot;0&quot;)<br/>
    Call ctx.ReplaceItemValue(&quot;RegistrationStatus&quot; ,&quot;REGKO&quot;)<br/>
    

    [snip]

    Exit Sub<br/>
    



    As I run this forum on my company intranet I do not need user registration but user would like to be able to edit their profiles.

    • The Agent Fix

      By Andrew Tetlaw 2 decades ago

      I was wrong with the code above.



      It's because you try to get a handle on the person document even though the forum config says NO to registration (and thus have not supplied any names.nsf details). So I changed this:



      'Check if registration is allowed

      If ctx.IsNewNote And profile.GetItemValue(&quot;AllowRegistration&quot;)(0) &lt;&gt; &quot;YES&quot; Then<br/>
          ErrorCode=&quot;1&quot;<br/>
          Goto ErrorHandler<br/>
      End If <br/>
      <br/>
      Set dbreg = s.GetDatabase(&quot;&quot;,profile.GetItemValue(&quot;NABFile&quot;)(0))<br/>
      Set dbreggroup = s.GetDatabase(&quot;&quot;,profile.GetItemValue(&quot;NABGroupFile&quot;)(0))<br/>
      <br/>
      Set viewreg=dbreg.GetView(&quot;($Users)&quot;)<br/>
      <br/>
      username = ctx.GetItemValue(&quot;Username&quot;)(0)<br/>
      Set docpeople = viewreg.GetDocumentByKey(username,True)<br/>
      <br/>
      If ctx.IsNewNote And Not (docpeople Is Nothing) Then <br/>
          ErrorCode=&quot;2&quot;<br/>
          Goto ErrorHandler<br/>
      End If<br/>
      





      to this:



      'Check if registration is allowed

      If ctx.IsNewNote And profile.GetItemValue(&quot;AllowRegistration&quot;)(0) &lt;&gt; &quot;YES&quot; Then<br/>
          ErrorCode=&quot;1&quot;<br/>
          Goto ErrorHandler<br/>
      End If <br/>
      <br/>
      If profile.GetItemValue(&quot;AllowRegistration&quot;)(0) = &quot;YES&quot; Then<br/>
          Set dbreg = s.GetDatabase(&quot;&quot;,profile.GetItemValue(&quot;NABFile&quot;)(0))<br/>
          Set dbreggroup = s.GetDatabase(&quot;&quot;,profile.GetItemValue(&quot;NABGroupFile&quot;)(0))<br/>
          <br/>
          Set viewreg=dbreg.GetView(&quot;($Users)&quot;)<br/>
          <br/>
          username = ctx.GetItemValue(&quot;Username&quot;)(0)<br/>
          Set docpeople = viewreg.GetDocumentByKey(username,True)<br/>
          <br/>
          If ctx.IsNewNote And Not (docpeople Is Nothing) Then <br/>
              ErrorCode=&quot;2&quot;<br/>
              Goto ErrorHandler<br/>
          End If<br/>
          <br/>
      End If