It should just work with the example dialplan, if you set the variables.
In my default dialplan, in an outbound file, I have this extension:

   <extension name="domestic 10-digit">
    <condition field="destination_number" expression="^\+?1?([2-9]\d\d[2-9]\d\d\
d{4})$">
      <action application="set" data="effective_caller_id_number=${outbound_call
er_id_number}"/>
      <action application="set" data="effective_caller_id_name=${outbound_caller
_name}"/>
      <action application="set" data="effective_callee_id_number=$1"/>
      <action application="set" data="effective_callee_id_name=${cidlookup(1$1)}
"/>
      <action application="set" data="ignore_display_updates=true"/>
      <!-- If your provider does not provide ringback (180 or 183) you may simul
ate
        ringback by uncommenting the following line. -->
      <!-- action application="ringback" /-->
      <!-- try an E.164 route -->
      <action application="set" data="continue_on_fail=true"/>
      <action application="enum" data="1$1 e164.org"/>
      <action application="bridge" data="${enum_auto_route}"/>
      <action application="enum" data="1$1 e164.arpa"/>
      <action application="bridge" data="${enum_auto_route}"/>
      <action application="bridge" data="sofia/gateway/$${default_provider}/1$1"
/>
     </condition>
   </extension>

This sets the CID number to the outbound_caller_id_number, which is a variable for each entry in the directory. A typical directory entry will look like this:

<include>
  <user id="516">
    <params>
...user stuff here...
    </params>
    <variables>
      <variable name="toll_allow" value="domestic,international,local"/>
      <variable name="accountcode" value="516"/>
      <variable name="user_context" value="default"/>
      <variable name="effective_caller_id_name" value="Damian Mendola"/>
      <variable name="effective_caller_id_number" value="516"/>
      <variable name="outbound_caller_id_name" value="$${outbound_caller_name}"/>
      <variable name="outbound_caller_id_number" value="$${outbound_caller_id}"/>
      <variable name="callgroup" value="sales"/>
    </variables>
  </user>
</include>

Some phones have a different outbound_caller_id, but most use our main line, which is set in vars.xml.

-- 
Steve


On Wed, Oct 15, 2014 at 9:06 AM, Joel White <joelewhite@gmail.com> wrote:
I am having an issue setting up CID for individual extensions


I am running out of a PostgreSQL DB and have created a Users Table

Using Lua I am dynamically generating the Directory

I have a column in the table for CID, but have been unsuccessful in implementing CID for outbound calling


I want the extension to display internally, but to add CID when calling outside of the system


How can I implement this?  And can it be done using Lua to dynamically lookup in the DB for each users CID?