Sage CRM 2019 integration

Status
Not open for further replies.

greychain

Gold Partner
Advanced Certified
Joined
Jul 13, 2018
Messages
779
Reaction score
122
I'm trying to use the 3CX template wizard to generate an integration template but am unable to get the initial search function to return a valid client ID. The problem I am having is that Sage only returns a phone record ID which you then need to specifiy in a seperate command to retrieve the client details.

Sage resolves to 192.168.1.236

Such as this:

I notice in the 3CX template generator you can specify additional scenarios and chain the together. Can the $key value be assigned a variable which is then passed to the second scenario?

http://192.168.1.236/sdata/crmj/sagecrm2/-/Phone?Where=Phon_number eq '620441' which returns

{
"$url": "http://sage/sdata/crmj/sagecrm2/-/Phone?where=Phon_number eq '620441'&startindex=1&count=10",
"$first": "http://sage/sdata/crmj/sagecrm2/-/Phone?where=Phon_number eq '620441'&startindex=1&count=10",
"$last": "http://sage/sdata/crmj/sagecrm2/-/Phone?where=Phon_number eq '620441'&startindex=1&count=10",
"$totalResults": 1,
"$startIndex": 1,
"$itemsPerPage": 10,
"$resources": [
{
"$key": 4065,
"$title": "",
"$url": "http://sage/sdata/crmj/sagecrm2/-/Phone('4065')",
"Phon_CountryCode": "855",
"phon_IntId": null,
"Phon_number": "620441",
"phon_promote": false,
"Phon_AreaCode": "012",
"phon_IntForeignID": null,
"phon_intlastsyncdate": null,
"Person": {
"$url": {
"Association": "http://sage/sdata/crmj/sagecrm2/-/Phone('4065')/Person?startindex=1&count=10"
}
},
"Company": {
"$url": {
"Association": "http://sage/sdata/crmj/sagecrm2/-/Phone('4065')/Company?startindex=1&count=10"
}
},
"Account": {
"$url": {
"Association": "http://sage/sdata/crmj/sagecrm2/-/Phone('4065')/Account?startindex=1&count=10"
}
}
}
]
}




You then need to do a http://192168.1.236/sdata/crmj/sagecrm2/-/Phone('4065')/Person?startindex=1&count=10 to retrieve the client details.

{
"$url": "http://sage/sdata/crmj/sagecrm2/-/Phone('4065')/Person?startindex=1&count=10",
"$first": "http://sage/sdata/crmj/sagecrm2/-/Phone('4065')/Person?startindex=1&count=10",
"$last": "http://sage/sdata/crmj/sagecrm2/-/Phone('4065')/Person?startindex=1&count=10",
"$totalResults": 1,
"$startIndex": 1,
"$itemsPerPage": 10,
"$resources": [
{
"$key": 1780,
"$title": "BArry OShaughnessy",
"$url": "http://sage/sdata/crmj/sagecrm2/-/Person('1780')",
"Pers_PersonId": 1780,
"Pers_SecTerr": -1845493753,
"Pers_PrimaryuserId": 1,
"Pers_IntegratedSystems": null,
"Pers_Gender": null,
"Pers_LibraryDir": "O\\OShaughnessy, BArry(I1780)",
"Pers_MiddleName": null,
"Pers_Salutation": null,
"Pers_MailRestriction": false,
"Pers_DepartmentCode": null,
"Pers_CreatedDate": "2019-08-14T10:40:27+01:00",
"Pers_Department": null,
"Pers_territory": null,
"Pers_IntForeignID": null,
"pers_Website": null,
"Pers_IntId": null,
"Pers_Title": null,
"Pers_ChannelId": null,
"Pers_UpdatedDate": "2019-08-14T10:40:27+01:00",
"Pers_CreatedBy": 1,
"Pers_PrimaryAddressId": 1780,
"Pers_intlastsyncdate": null,
"Pers_FirstName": "BArry",
"Pers_TitleCode": null,
"pers_source": null,
"Pers_WorkflowID": null,
"pers_promote": false,
"Pers_UpdatedBy": 1,
"Pers_OptOut": false,
"Pers_ConflictResDate": null,
"Pers_LastName": "OShaughnessy",
"Pers_CompanyId": 740,
"Pers_AccountId": null,
"pers_status": null,
"Pers_Suffix": null,
"Company": {
"$url": [
{
"Reference": "http://sage/sdata/crmj/sagecrm2/-/Company('740')"
},
{
"Association": "http://sage/sdata/crmj/sagecrm2/-/Person('1780')/Company?startindex=1&count=10"
}
]
},
"Address": {
"$url": [
{
"Reference": "http://sage/sdata/crmj/sagecrm2/-/Address('1780')"
},
{
"Association": "http://sage/sdata/crmj/sagecrm2/-/Person('1780')/Address?startindex=1&count=10"
}
]
},
"Users": {
"$url": [
{
"Reference": "http://sage/sdata/crmj/sagecrm2/-/Users('1')"
}
]
},
"Account": {},
"Library": {
"$url": {
"Association": "http://sage/sdata/crmj/sagecrm2/-/Person('1780')/Library?startindex=1&count=10"
}
},
"Phone": {
"$url": {
"Association": "http://sage/sdata/crmj/sagecrm2/-/Person('1780')/Phone?startindex=1&count=10"
}
},
"Cases": {
"$url": {
"Association": "http://sage/sdata/crmj/sagecrm2/-/Person('1780')/Cases?startindex=1&count=10"
}
},
"Opportunity": {
"$url": {
"Association": "http://sage/sdata/crmj/sagecrm2/-/Person('1780')/Opportunity?startindex=1&count=10"
}
},
"Email": {
"$url": {
"Association": "http://sage/sdata/crmj/sagecrm2/-/Person('1780')/Email?startindex=1&count=10"
}
},
"Communication": {
"$url": {
"Association": "http://sage/sdata/crmj/sagecrm2/-/Person('1780')/Communication?startindex=1&count=10"
}
}
}
]
}
 
I notice in the 3CX template generator you can specify additional scenarios and chain the together. Can the $key value be assigned a variable which is then passed to the second scenario?
Yes, you can. You need 2 scenarios, you get the key in the first request, and then configure the Output to start a second scenario which will get the details. Any variable from the first scenario can be used in the second. For example, if you define a variable named "ContactKey", you can access the value in the second scenario using it in brackets: [ContactKey]. You need to do this using the "manual" approach, the Wizard will not let you define this.
 
Thanks for that Ernesto. Do I refer to the values returned as $key or just key?

So a personal first name (Pers_Firstname) would be referred to as $resources.Pers_Firstname or would it be resources.Pers_Firstname
 
Yes, you need to include the $ because it's part of the property name.
 
Thanks for the help so far, is there a manual that goes with this APP ?

Could you give me an example of using a variable from the first scenario as a input for the second scenario?

From the first scenario I get a ContactID=4065 for the second scenario do I just use this as the parameter?

http://sage/sdata/crmj/sagecrm2/-/Phone('[ContactID')/Person and then use the json returned by this command to extract Firstname - $resources.Per_FirstName and LastName -
$resources.Per_LastName?
 
Yes, that's it. Please note that you have a typo, you need to add opening and closing brackets to use a variable:
[ContactID]
 
Last edited:
So now I'm getting the 2nd scenario to trigger but it is not assigning any values to variables. Here is some of the response tree from the second scenario and the variable assignment screen.
To define the variables I right clicked the item in the Response tree and used the Add variable option to create the variable and define the output.

When I click on the variables tab I cannot see any variables being defined. I can see the variables for the first scenario.

What am I doing wrong?

1193611937
 
here is the xml

XML:
<?xml version="1.0"?>

<Crm xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Country="US" Name="test1" Version="0">

  <Number Prefix="AsIs" MaxLength="7" />

  <Connection MaxConcurrentRequests="2" />

  <Parameters>

    <Parameter Name="URL" Type="String" Parent="General Configuration" Editor="String" Title="URL:" />

    <Parameter Name="UserName" Type="String" Parent="General Configuration" Editor="String" Title="Username:" />

    <Parameter Name="Password" Type="Password" Parent="General Configuration" Editor="String" Title="Password:" />

  </Parameters>

  <Authentication Type="Basic">

    <Value>[UserName]:[Password]</Value>

  </Authentication>

  <Scenarios>

    <Scenario Type="REST">

      <Request SkipIf="" Url="Phone?Where=Phon_number eq '[Number]'" MessagePasses="0" RequestEncoding="UrlEncoded" RequestType="Get" ResponseType="Json" />

      <Rules>

        <Rule Type="Any">$resources.$key</Rule>

      </Rules>

      <Variables>

        <Variable Name="PhoneID" Path="$resources.$key">

          <Filter />

        </Variable>

        <Variable Name="ContactID" Path="$resources.$key">

          <Filter />

        </Variable>

        <Variable Name="Phon_number">$resources.Phon_number<Filter /></Variable>

        <Variable Name="Association">$resources.Person.$url.Association<Filter /></Variable>

      </Variables>

      <Outputs Next="contact" AllowEmpty="false">

        <Output Type="PhoneID" Passes="0" Value="[PhoneID]" />

        <Output Type="FirstName" Passes="0" Value="[PhoneID]" />

      </Outputs>

    </Scenario>

    <Scenario Id="contact" Type="REST">

      <Request Url="[URL]Phone('[PhoneID]')/Person" MessagePasses="0" RequestEncoding="UrlEncoded" RequestType="Get" ResponseType="Json" />

      <Rules>

        <Rule Type="Any">[PhoneID]</Rule>

      </Rules>

      <Variables>

        <Variable Name="Pers_FirstName">$resources.Pers_FirstName<Filter /></Variable>

        <Variable Name="Pers_LastName">$resources.Pers_LastName<Filter /></Variable>

        <Variable Name="PhoneBusiness" Path="[Phon_number]">

          <Filter />

        </Variable>

        <Variable Name="ContactID">$resources.$key<Filter /></Variable>

      </Variables>

      <Outputs AllowEmpty="false">

        <Output Type="PhoneBusiness" Passes="0" Value="[PhoneBusiness]" />

        <Output Type="FirstName" Passes="0" Value="[Pers_FirstName]" />

        <Output Type="LastName" Passes="0" Value="[Pers_LastName]" />

        <Output Type="contactID" Passes="0" Value="[ContactID]" />

      </Outputs>

    </Scenario>

  </Scenarios>

</Crm>
 
Probably the Rules for the second scenario:
<Rule Type="Any">[PhoneID]</Rule>

Are not matching any record. Then, variables are not matched. You need to match the records first. So, ensure that the response has the path that you are specifying there. What are you assigning to [PhoneID] in the first scenario?
 
Yes changing that to $resources.$key worked. Now the only other issue I have is using variables from the first scenario.

In the first scenario I define a variable phon_number then in the second scenario I try to assign the value of this variable to the variable PhoneBusiness by setting the path to [phon_number] . How do I reference variables from the first scenario? I thought they passed thru to the next scenario if it was chained.
 
Variables can only be set from JSON/XML path, not from other variable. Actually, it makes no sense to set a variable with another variable. You can just use the variable from the first scenario to set the output of the second scenario.
 
I did try using the $resources.Phon_number returned from the first scenario but it didn't carry through


11969 first scenario

11970second scenario
 
I ended up putting the PhoneBusiness variable in the first scenario and it picked it up in the outputs of the second scenario.

Thanks for your help.
 
I ended up putting the PhoneBusiness variable in the first scenario and it picked it up in the outputs of the second scenario.
That's what I was suggesting you to do. Glad to see that you have it working now.
 
In the end it made no difference, the Sage web interface doesn't send any actual client URL's that can be applied directly as in a direct link to a customer info page, plus you need to be logged into Sage before you can access the customer page and have access to the token for that session even if it did.
 
Status
Not open for further replies.

Latest Posts

Forum statistics

Threads
112,324
Messages
591,897
Members
165,475
Latest member
lastshadow