• javascript error when you try to add persons that are not selected...

    By Vlad Chivulescu 1 decade ago

    When you use NP_openPopup(this.id,"",this.name,'M',") and click on "add" button without having selected any doc it happens nothing. You realize it and select a person. When you click on "OK" button you will see an empty line, the person that you selected has been added and a java script error: "'NP_selectedPeople.0.name' is null or not an object". It can be easily fixed if you add an if statement after eIndex = selectA.selectedIndex statement in NP_add2Select(e) function (see below):


    eIndex = selectA.selectedIndex;<br/>
    if (eIndex &lt; 0) return;<br/>
    



    thanks

    vlad



    PS: Steve, I have implemented the AD search. It is slower than Outlook window but it is ok. My main problem with Outlook was that on a company laptop with IE7 and Vista I was getting an error (it does not happen in XP with IE6). The main challenge with AD was to find the "rigth" server. It means that in my case the AD servers from a country have only people from that country. For a global search it is a special server (the filter that I apply is the same).

    • Fixed It

      By Steve McDonagh 1 decade ago

      Thanks Vlad!

      I have put your fix in the current Version



      I would be very interested in seeing your AD code if you would like to share it :)



      Steve

      • NP_getNameLS code modified to use Active Directory

        By Vlad Chivulescu 1 decade ago

        Hi Steve



        In "NP_getNameLS" Lotus Script agent I have modified only "NP_findName" and "NP_findSelected". Also I have modified the Name Picker behaviour. It is like in outlook or domino address book now: you enter a letter it will display the first 95 persons that have the name starting with that letter, you enter the second letter it will display the first 95 persons that have the name starting with that two letters, etc. Some validations are performed due a lot of garbages that are in global AD. I do not think that it will be possible to use it like you use it now (search the names that contain a group of letters). Searching AD is like appying a filter…



        Sub NP_findName(PAB As String,Key As String)

        On Error Goto errorhandler<br/>
        Dim agentLog As New NotesLog(&quot;Agent log&quot;)<br/>
        Call agentLog.OpenAgentLog<br/>
        Call agentLog.LogAction(&quot;Find Name ok vlad PAB=&quot; + PAB + &quot; Key=&quot; + Key)     <br/>
        <br/>
        Dim conn As Variant, cmd As Variant, result As Variant<br/>
        <br/>
        Const AD_SEARCH_ROOT_GLOBAL = &quot;GC://dc=acme,dc=com&quot;  ' Host for global AD searches<br/>
        Const GROUP_ATTRIBUTE_LIST = &quot;showinaddressbook,DisplayName,mail,l,telephoneNumber,manager,Department,sAMAccountName, distinguishedName&quot;<br/>
        Call agentLog.LogAction(&quot;Step01 &quot;)<br/>
        <br/>
        Set conn = CreateObject(&quot;ADODB.Connection&quot;)<br/>
        Call conn.Open(&quot;Provider=ADsDSOObject;&quot;)<br/>
        Set cmd = CreateObject(&quot;ADODB.Command&quot;)<br/>
        Set cmd.ActiveConnection = conn<br/>
        cmd.Properties(&quot;Page Size&quot;) = 100<br/>
        Do <br/>
            If stepf &gt;=1 Then If Len(Key) = 1 Then Exit Sub Else Key = Mid$(Key, 1, Len(Key) - 1)<br/>
            filter = &quot;(DisplayName=&quot; + Key + &quot;*)&quot;<br/>
            cmdtxt$ = &quot;&lt;&quot; &amp; AD_SEARCH_ROOT_GLOBAL &amp; &quot;&gt;;&quot; &amp; filter &amp; &quot;;&quot; &amp; GROUP_ATTRIBUTE_LIST &amp; &quot;;subtree&quot;<br/>
            cmd.CommandText = cmdtxt$ <br/>
            Set result = cmd.Execute()<br/>
            stepf = stepf + 1<br/>
        Loop Until Not result.EOF<br/>
        <br/>
        Call agentLog.LogAction(&quot;Stepf: &quot; + Cstr(Stepf))<br/>
        Do While Not result.EOF<br/>
            mgcount = mgcount + 1<br/>
            If Isnull(result.Fields(&quot;showinaddressbook&quot;).value) Then UShow = &quot;&quot; Else UShow = result.Fields(&quot;showinaddressbook&quot;).value<br/>
            isar = Isarray( UShow )<br/>
            If isar Then<br/>
                UsAMAccountName$ = result.Fields(&quot;sAMAccountName&quot;).value<br/>
                UName$ = result.Fields(&quot;DisplayName&quot;).value<br/>
                If Isnull(result.Fields(&quot;mail&quot;).value) Then UEmaddy$ = &quot;&quot; Else UEmaddy$= result.Fields(&quot;mail&quot;).value<br/>
                If Isnull(result.Fields(&quot;l&quot;).value) Then ULocation$ = &quot;&quot; Else ULocation$ = result.Fields(&quot;l&quot;).value<br/>
                If Isnull(result.Fields(&quot;telephoneNumber&quot;).value) Then UPhone$ = &quot;&quot; Else UPhone$ = result.Fields(&quot;telephoneNumber&quot;).value<br/>
                If Isnull(result.Fields(&quot;manager&quot;).value) Then UManager$ = &quot;&quot; Else UManager$ = result.Fields(&quot;manager&quot;).value<br/>
                If Isnull(result.Fields(&quot;Department&quot;).value) Then UDepartment$ = &quot;&quot; Else UDepartment$ = result.Fields(&quot;Department&quot;).value<br/>
                mytext = &quot;&quot;<br/>
                mytext = mytext+|name: &quot;|+UName$ +|&quot;, |<br/>
                mytext = mytext+|sname: &quot;|+UsAMAccountName$ +|&quot;, |<br/>
                mytext= mytext+|pab: &quot;|+AD_SEARCH_ROOT_GLOBAL+|&quot;,|<br/>
                mytext = mytext+|email: &quot;|+UEmaddy$ +|&quot;, |<br/>
                mytext = mytext+|location: &quot;| + ULocation$ +|&quot;, |         <br/>
                mytext = mytext+|department: &quot;| + UDepartment$ + |&quot;, |<br/>
                mytext = mytext+|ophone: &quot;|+UPhone$+|&quot;, |<br/>
                mytext = mytext+|mphone: &quot;|+UCellphonenumber$+|&quot;, |<br/>
                mytext = mytext+|fax: &quot;|+UOfficefaxphonenumber+|&quot;, |          <br/>
                mytext = mytext+|manager: &quot;|+UManager$ +|&quot;|           <br/>
                'Call agentLog.LogAction(&quot;i=&quot; + Cstr(i) + &quot; mytext: &quot; + mytext)<br/>
                'mytext = Replace(mytext, &quot;'&quot;, &quot;'&quot;)<br/>
                Print |NP_names.push( { |+mytext+| } );|<br/>
            End If<br/>
            Call result.MoveNext()<br/>
            If mgcount &gt; 95 Then Exit Do     <br/>
        Loop<br/>
        Exit Sub<br/>
        

        ErrorHandler:

        Call agentLog.LogAction(&quot;Error : &quot; + Error())<br/>
        

        ' Print Error(), Err(), Erl()

        ' Msgbox( Error$ )

        Exit Sub<br/>
        

        End Sub





        Sub NP_findSelected(PAB As String,Key As Variant)

        Dim conn As Variant, cmd As Variant, result As Variant<br/>
        <br/>
        Const AD_SEARCH_ROOT_GLOBAL = &quot;GC://dc=acme,dc=com&quot;  ' Host for global AD searches<br/>
        Const GROUP_ATTRIBUTE_LIST = &quot;DisplayName,mail,l,telephoneNumber,manager,Department,sAMAccountName, distinguishedName&quot;<br/>
        <br/>
        Set conn = CreateObject(&quot;ADODB.Connection&quot;)<br/>
        Call conn.Open(&quot;Provider=ADsDSOObject;&quot;)<br/>
        Set cmd = CreateObject(&quot;ADODB.Command&quot;)<br/>
        Set cmd.ActiveConnection = conn<br/>
        cmd.Properties(&quot;Page Size&quot;) = 100<br/>
        If stepf &gt;=1 Then If Len(Key) = 1 Then Exit Sub Else Key = Mid$(Key, 1, Len(Key) - 1)<br/>
        filter = &quot;(mail=&quot; + Key + &quot;)&quot;<br/>
        cmdtxt$ = &quot;&lt;&quot; &amp; AD_SEARCH_ROOT_GLOBAL &amp; &quot;&gt;;&quot; &amp; filter &amp; &quot;;&quot; &amp; GROUP_ATTRIBUTE_LIST &amp; &quot;;subtree&quot;<br/>
        cmd.CommandText = cmdtxt$ <br/>
        Set result = cmd.Execute()<br/>
        If Not result.EOF Then<br/>
            mgcount = mgcount + 1<br/>
            UName$ = result.Fields(&quot;DisplayName&quot;).value<br/>
            If Isnull(result.Fields(&quot;mail&quot;).value) Then UEmaddy$ = &quot;&quot; Else UEmaddy$= result.Fields(&quot;mail&quot;).value<br/>
            If Isnull(result.Fields(&quot;l&quot;).value) Then ULocation$ = &quot;&quot; Else ULocation$ = result.Fields(&quot;mail&quot;).value<br/>
            If Isnull(result.Fields(&quot;telephoneNumber&quot;).value) Then UPhone$ = &quot;&quot; Else UPhone$ = result.Fields(&quot;telephoneNumber&quot;).value<br/>
            If Isnull(result.Fields(&quot;manager&quot;).value) Then UManager$ = &quot;&quot; Else UManager$ = result.Fields(&quot;manager&quot;).value<br/>
            If Isnull(result.Fields(&quot;Department&quot;).value) Then UDepartment$ = &quot;&quot; Else UDepartment$ = result.Fields(&quot;Department&quot;).value<br/>
            mytext = &quot;&quot;<br/>
            mytext = mytext+|name: &quot;|+UName$ +|&quot;, |<br/>
            mytext = mytext+|sname: &quot;|+UName$ + &quot; common &quot; +|&quot;, |<br/>
            mytext= mytext+|pab: &quot;|+AD_SEARCH_ROOT_GLOBAL+|&quot;,|<br/>
            mytext = mytext+|email: &quot;|+UEmaddy$ +|&quot;, |<br/>
            mytext = mytext+|location: &quot;| + ULocation$ +|&quot;, |         <br/>
            mytext = mytext+|department: &quot;| + UDepartment$ + |&quot;, |<br/>
            mytext = mytext+|ophone: &quot;|+UPhone$+|&quot;, |<br/>
            mytext = mytext+|mphone: &quot;|+UCellphonenumber$+|&quot;, |<br/>
            mytext = mytext+|fax: &quot;|+UOfficefaxphonenumber+|&quot;, |          <br/>
            mytext = mytext+|manager: &quot;|+UManager$ +|&quot;|           <br/>
            Print |NP_selectedPeople.push( { |+mytext+| } );|<br/>
        End If<br/>
        <br/>
        

        End Sub