Problem with filling the address book from CRM

Status
Not open for further replies.

Altapo

Customer
Joined
Jul 2, 2021
Messages
2
Reaction score
0
Using 3CX CRM Template Generator, a template for integration with your own CRM system was created.
The problem is that every time an unknown number is requested, the 3CX address book is overwritten (advanced - > contacts), the numbers are not added to the id of the record, and the new record overwrites the previous one. In fact, I always have one entry in the address book with data from the last CRM request.

Template
XML:
<?xml version="1.0"?>
<Crm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Country="US" Name="ERP" Version="1">
  <Number Prefix="AsIs" MaxLength="[MaxLength]" />
  <Connection MaxConcurrentRequests="2" />
  <Parameters />
  <Authentication Type="No" />
  <Scenarios>
    <Scenario Id="" Type="REST">
      <Request Url="https://domain.com/api/org/contact/[Number]" MessagePasses="0" RequestEncoding="UrlEncoded" RequestType="Get" ResponseType="Json" />
      <Rules>
        <Rule Type="Any">item.id</Rule>
      </Rules>
      <Variables>
        <Variable Name="ContactID" Path="item.id">
          <Filter />
        </Variable>
        <Variable Name="FirstName" Path="item.firstname">
          <Filter />
        </Variable>
        <Variable Name="LastName" Path="item.lastname">
          <Filter />
        </Variable>
        <Variable Name="CompanyName" Path="item.company">
          <Filter />
        </Variable>
        <Variable Name="Email" Path="item.email">
          <Filter />
        </Variable>
        <Variable Name="PhoneBusiness" Path="item.phone1">
          <Filter />
        </Variable>
        <Variable Name="PhoneBusiness2" Path="item.phone2">
          <Filter />
        </Variable>
        <Variable Name="PhoneMobile" Path="item.phone3">
          <Filter />
        </Variable>
        <Variable Name="PhoneMobile2" Path="item.phone4">
          <Filter />
        </Variable>
        <Variable Name="CustomValue" Path="item.custom">
          <Filter />
        </Variable>
        <Variable Name="ContactUrl" Path="item.url">
          <Filter />
        </Variable>
      </Variables>
      <Outputs AllowEmpty="false">
        <Output Type="ContactID" Passes="0" Value="[ContactID]" />
        <Output Type="FirstName" Passes="0" Value="[FirstName]" />
        <Output Type="LastName" Passes="0" Value="[LastName]" />
        <Output Type="CompanyName" Passes="0" Value="[CompanyName]" />
        <Output Type="Email" Passes="0" Value="[Email]" />
        <Output Type="PhoneBusiness" Passes="0" Value="[PhoneBusiness]" />
        <Output Type="PhoneBusiness2" Passes="0" Value="[PhoneBusiness2]" />
        <Output Type="PhoneMobile" Passes="0" Value="[PhoneMobile]" />
        <Output Type="PhoneMobile2" Passes="0" Value="[PhoneMobile2]" />
        <Output Type="CustomValue" Passes="0" Value="[CustomValue]" />
        <Output Type="ContactUrl" Passes="0" Value="[ContactUrl]" />
      </Outputs>
    </Scenario>
  </Scenarios>
</Crm>

Result
JSON:
[
  {
    "UnparsedOutputs": {
      "ContactID": "100001",
      "FirstName": "Иван",
      "LastName": "Иванов",
      "CompanyName": "ООО «Рога и копыта»",
      "Email": "[email protected]",
      "PhoneBusiness": "",
      "PhoneBusiness2": "",
      "PhoneMobile": "79090123456",
      "PhoneMobile2": "",
      "CustomValue": "",
      "ContactUrl": ""
    },
    "FirstName": "Иван",
    "LastName": "Иванов",
    "Email": "[email protected]",
    "ContactUrl": "",
    "CompanyName": "ООО «Рога и копыта»",
    "PhotoUrl": null,
    "ContactType": 0,
    "PhoneBusiness": "",
    "PhoneBusiness2": "",
    "PhoneHome": null,
    "PhoneHome2": null,
    "PhoneMobile": "79090123456",
    "PhoneMobile2": "",
    "PhoneOther": null,
    "FaxBusiness": null,
    "FaxHome": null,
    "Pager": null
  }
]

CRM journal
Code:
Started scenario with empty id
Request text: https://domain.com/api/org/contact/9090123456
Response text: {"item":{"id":100001,"firstname":"Иван","lastname":"Иванов","company":"ООО «Рога и копыта»","email":"[email protected]","phone3":"79090123456"}}
Response finished
Variable ContactID set to 100001
Variable FirstName set to Иван
Variable LastName set to Иванов
Variable CompanyName set to ООО «Рога и копыта»
Variable Email set to [email protected]
Variable PhoneBusiness set to
Variable PhoneBusiness2 set to
Variable PhoneMobile set to 79090123456
Variable PhoneMobile2 set to
Variable CustomValue set to
Variable ContactUrl set to
Finished scenario with empty id
Result obtained
 
The issue here is that your ContactUrl variable is empty. Your path "item.url" doesn't seem to get any data.

3CX uses the ContactUrl as the Primary Key for contacts. This way, the name, number and everything can change, but the URL will always be the same (generally, something like "url/contacts/[ContactID]".)

Once you provide a ContactUrl, it should stop creating duplicates.
 
The issue here is that your ContactUrl variable is empty. Your path "item.url" doesn't seem to get any data.

3CX uses the ContactUrl as the Primary Key for contacts. This way, the name, number and everything can change, but the URL will always be the same (generally, something like "url/contacts/[ContactID]".)

Once you provide a ContactUrl, it should stop creating duplicates.
Thank you, it helped
 
Status
Not open for further replies.

Latest Posts

Forum statistics

Threads
112,323
Messages
591,896
Members
165,474
Latest member
costionofrei