Get Phone with specific Directory Number (Line)

Version 1
    This document was generated from CDN thread

    Created by: Juerg Ott on 22-01-2013 08:24:29 AM
    i searching the best way to find the phone device with a specific line number.
    with the Unified CM Administration Webinterface i can easy find them with Device - Phone and then as Filter
    Find Phone where "Directory Number" begins with "1000" 
    But if i want to do this with AXL, i cannot set a "Directory Number" Filter in ListPhoneReqSearchCriteria() 
    can somebody give me the correct way get the Phone Device with has a specific Directory Number?
    thanks
    Jürg

    Subject: RE: Get Phone with specific Directory Number (Line)
    Replied by: Leandro Wajswajn on 22-01-2013 08:56:06 AM
    I'm not sure if you can search through Line # within AXL; what I found that you can do is to use an "executeSQLQuery" command and build yourown SQL Query for what you need. In your case, to list all phone name (SEPXXXXXXXX) which its line starts with "1000", you will need to run this query:
    SELECT device.name
    FROM device
    INNER JOIN devicenumplanmap ON devicenumplanmap.fkdevice=device.pkid
    INNER JOIN numplan ON devicenumplanmap.fknumplan=numplan.pkid
    WHERE numplan.dnorpattern LIKE '1000%'
    The whole SOAP XML would be:
    <axl:executeSQLQuery xmlns:axl="http://www.cisco.com/AXL/API/8.5" xsi:schemaLocation="http://www.cisco.com/AXL/API/8.5 axlsoap.xsd">
        <sql>SELECT device.name FROM device INNER JOIN devicenumplanmap ON devicenumplanmap.fkdevice=device.pkid INNER JOIN numplan ON devicenumplanmap.fknumplan=numplan.pkid WHERE numplan.dnorpattern LIKE '1000%'</sql>
    </axl:executeSQLQuery>

    Subject: RE: Get Phone with specific Directory Number (Line)
    Replied by: Juerg Ott on 23-01-2013 09:37:51 AM
    thanks Leandro, works perfect!