2 scenarios the first without result the second with result

Status
Not open for further replies.

Enginelab

New User
Joined
Sep 3, 2021
Messages
5
Reaction score
1
Hi everyone, this is the first time I write in the forum!
I'm trying to complete the integration with our custom CRM. I have 2 scenarios the first makes a call and queries the people table if the phone number is present everything is fine if the number is not present it responds with an empty json. At this point he moves on to the second scenario which queries the company table and the telephone number is present but since the crm previously answered him with an empty json, the switchboard does not consider me the second answer which is instead "full".

below part of the xml

<Scenario Id="" Type="REST" EntityId="1" EntityOrder="2">
<Request SkipIf="[FoundRecordCount]==0" Url="?opt=contatti&amp;num=[Number]&amp;...the results of the second Many thanks to all
 
You should use the EntityType and EntityOrder. Look at the Salesforce or HubSpot templates to find how.

It requires a parameter and the 2 scenarios. They will not be "chained" but rather executed if needed (if the first returns nothing).

No need for the SkipIf either in that case.
 
This expression will cause that the scenario is skipped if there are no records found in the first scenario:
SkipIf="[FoundRecordCount]==0"

You probably want to use the following instead:
SkipIf="[IIf([FoundRecordCount]&gt;0,True,False)]"
 
  • Like
Reactions: Evolute IT
This expression will cause that the scenario is skipped if there are no records found in the first scenario:
SkipIf="[FoundRecordCount]==0"

You probably want to use the following instead:
SkipIf="[IIf([FoundRecordCount]&gt;0,True,False)]"
Thanks for the answer, in the first version of the template I used the expression you indicated but nothing changed.
 
Thanks for the answer, in the first version of the template I used the expression you indicated but nothing changed.
Can you share your template so we can take a look and see what's wrong?
 
  • Like
Reactions: Evolute IT
You should use the EntityType and EntityOrder. Look at the Salesforce or HubSpot templates to find how.

It requires a parameter and the 2 scenarios. They will not be "chained" but rather executed if needed (if the first returns nothing).

No need for the SkipIf either in that case.
Thanks for the answer, these two templare are too complex for my knowledge, perhaps a more didactic approach would help me better understand how to modify my template.
Best regards
 
Can you share your template so we can take a look and see what's wrong?
XML:
<?xml version="1.0"?>
<Crm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Country="IT" Name="MyCrm" Version="8" SupportsEmojis="false">
  <Number Prefix="Off" MaxLength="10" />
  <Connection MaxConcurrentRequests="8" />

  <Scenarios>
    <Scenario Id="" Type="REST" EntityId="1" EntityOrder="2">
      <Request SkipIf="[IIf([FoundRecordCount]&gt;0,True,False)]" Url="[Url]?opt=people&amp;num=[Number]&amp;type=[CallDirection]" MessagePasses="0" RequestEncoding="UrlEncoded" RequestType="Get" ResponseType="Json" />
      <Rules>
        <Rule Type="Any">id</Rule>
      </Rules>
      <Variables>
        <Variable Name="id" Path="id">
          <Filter />
        </Variable>
        <Variable Name="FirstName" Path="nome">
          <Filter />
        </Variable>
        <Variable Name="LastName" Path="cognome">
          <Filter />
        </Variable>
        <Variable Name="CompanyName" Path="azienda">
          <Filter />
        </Variable>
        <Variable Name="Email" Path="email">
          <Filter />
        </Variable>
        <Variable Name="PhoneBusiness" Path="telefono">
          <Filter />
        </Variable>
        <Variable Name="PhoneMobile" Path="cellulare">
          <Filter />
        </Variable>
      </Variables>
      <Outputs Next="" AllowEmpty="true">
        <Output Type="id" Passes="0" Value="[id]" />
        <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="PhoneMobile" Passes="0" Value="[PhoneMobile]" />
        <Output Type="ContactUrl" Passes="0" Value="https://crm.mysite.com/people/modifica.html?id=[id]" />
      </Outputs>
    </Scenario>
    <Scenario Id="" Type="REST" EntityId="2" EntityOrder="1">
      <Request SkipIf="[IIf([FoundRecordCount]&gt;0,True,False)]" Url="[Url]?opt=factory&amp;num=[Number]&amp;type=[CallDirection]" MessagePasses="0" RequestEncoding="UrlEncoded" RequestType="Get" ResponseType="Json" />
      <Rules>
        <Rule Type="Any">id</Rule>
      </Rules>
      <Variables>
        <Variable Name="accountID" Path="id">
          <Filter />
        </Variable>
        <Variable Name="Azienda" Path="nome">
          <Filter />
        </Variable>
        <Variable Name="Citta" Path="citta">
          <Filter />
        </Variable>
        <Variable Name="PhoneBusiness" Path="telefono">
          <Filter />
        </Variable>
      </Variables>
      <Outputs Next="" AllowEmpty="true">
        <Output Type="accountID" Passes="0" Value="[accountID]" />
        <Output Type="Nome" Passes="0" Value="[Azienda]" />
        <Output Type="Citta" Passes="0" Value="[Citta]" />
        <Output Type="PhoneBusiness" Passes="0" Value="[PhoneBusiness]" />
        <Output Type="ContactUrl" Passes="0" Value="https://crm.mysite.com/factory/modifica.html?id=[id]" />
      </Outputs>
    </Scenario>
    <Scenario Id="ReportCall" Type="REST">
      <Request SkipIf="[ReportCallEnabled]!=True||[CallType]!=Inbound" Url="[Url]?opt=Inbound&amp;num=[Number]" MessagePasses="0" Message="{ &quot;id&quot;: &quot;[id]&quot;, &quot;telefono&quot;: &quot;[Number]&quot;, &quot;cellulare&quot;: &quot;[Number]&quot;, &quot;testo&quot;: &quot;[Subject]&quot;, &quot;datatime&quot;:&quot;[DateTime]&quot;, &quot;start&quot;:&quot;[CallStartTimeLocal]&quot;, &quot;end&quot;:&quot;[CallEndTimeLocal]&quot;}" RequestContentType="application/json" RequestEncoding="UrlEncoded" RequestType="Post" ResponseType="Json">
        <PostValues Key="">
          <Value Key="id" Passes="1" Type="String">[id]</Value>
          <Value Key="tipo" Passes="1" Type="String">[CallType]</Value>
          <Value Key="durata" Passes="1" Type="String">[Duration]</Value>
          <Value Key="telefono" Passes="1" Type="String">[Number]</Value>
          <Value Key="incarico" Passes="1" Type="String">[Agent]</Value>
          <Value Key="data" Passes="1" Type="String">[DateTime]</Value>
          <Value Key="start" Passes="1" Type="String">[CallStartTimeLocal]</Value>
          <Value Key="end" Passes="1" Type="String">[CallEndTimeLocal]</Value>
        </PostValues>
      </Request>
      <Rules>
        <Rule Type="Any" Ethalon="">id</Rule>
      </Rules>
      <Variables>
        <Variable Name="id" Path="id">
          <Filter />
        </Variable>
      </Variables>
      <Outputs Next="ReportCallMissed" AllowEmpty="true" />
    </Scenario>
    <Scenario Id="ReportCallMissed" Type="REST">
      <Request SkipIf="[ReportCallEnabled]!=True||[CallType]!=Missed" Url="[Url]?opt=Missed&amp;num=[Number]" MessagePasses="0" Message="{ &quot;id&quot;: &quot;[EntityID]&quot;,  &quot;telefono&quot;: &quot;[Number]&quot;,  &quot;cellulare&quot;: &quot;[Number]&quot;,  &quot;testo&quot;: &quot;[MissedCallText]&quot;, &quot;datatime&quot;:&quot;[DateTime]&quot; }" RequestContentType="application/json" RequestEncoding="UrlEncoded" RequestType="Post" ResponseType="Json">
        <PostValues Key="">
          <Value Key="id" Passes="1" Type="String">[id]</Value>
          <Value Key="tipo" Passes="1" Type="String">[CallType]</Value>
          <Value Key="durata" Passes="1" Type="String">[Duration]</Value>
          <Value Key="telefono" Passes="1" Type="String">[Number]</Value>
          <Value Key="incarico" Passes="1" Type="String">[Agent]</Value>
          <Value Key="data" Passes="1" Type="String">[DateTime]</Value>
          <Value Key="start" Passes="1" Type="String">[CallStartTimeLocal]</Value>
          <Value Key="end" Passes="1" Type="String">[CallEndTimeLocal]</Value>
        </PostValues>
      </Request>
      <Variables />
      <Outputs Next="ReportCallOutbound" AllowEmpty="true" />
    </Scenario>
    <Scenario Id="ReportCallOutbound" Type="REST">
      <Request SkipIf="[ReportCallEnabled]!=True||[CallType]!=Outbound" Url="[Url]?opt=Outbound&amp;num=[Number]" MessagePasses="0" Message="{ &quot;id&quot;: &quot;[id]&quot;, &quot;telefono&quot;: &quot;[Number]&quot;, &quot;cellulare&quot;: &quot;[Number]&quot;, &quot;testo&quot;: &quot;[OutboundCallText]&quot;, &quot;datatime&quot;:&quot;[DateTime]&quot;, &quot;start&quot;:&quot;[CallStartTimeLocal]&quot;, &quot;end&quot;:&quot;[CallEndTimeLocal]&quot;}" RequestContentType="application/json" RequestEncoding="UrlEncoded" RequestType="Post" ResponseType="Json">
        <PostValues Key="">
          <Value Key="id" Passes="1" Type="String">[id]</Value>
          <Value Key="tipo" Passes="1" Type="String">[CallType]</Value>
          <Value Key="durata" Passes="1" Type="String">[Duration]</Value>
          <Value Key="telefono" Passes="1" Type="String">[Number]</Value>
          <Value Key="incarico" Passes="1" Type="String">[Agent]</Value>
          <Value Key="data" Passes="1" Type="String">[DateTime]</Value>
          <Value Key="start" Passes="1" Type="String">[CallStartTimeLocal]</Value>
          <Value Key="end" Passes="1" Type="String">[CallEndTimeLocal]</Value>
        </PostValues>
      </Request>
      <Variables />
      <Outputs Next="ReportCallNotanswered" AllowEmpty="true" />
    </Scenario>
    <Scenario Id="ReportCallNotanswered" Type="REST">
      <Request SkipIf="[ReportCallEnabled]!=True||[CallType]!=Notanswered" Url="[Url]?opt=Notanswered&amp;num=[Number]" MessagePasses="0" Message="{ &quot;id&quot;: &quot;[EntityID]&quot;,  &quot;telefono&quot;: &quot;[Number]&quot;,  &quot;telefono&quot;: &quot;[Number]&quot;,  &quot;testo&quot;: &quot;[NotAnsweredOutboundCallText]&quot;, &quot;datatime&quot;:&quot;[DateTime]&quot;, &quot;tipo&quot; : [CallDirection], &quot;durata&quot;:[Duration] }" RequestContentType="application/json" RequestEncoding="UrlEncoded" RequestType="Post" ResponseType="Json">
        <PostValues Key="">
          <Value Key="id" Passes="1" Type="String">[id]</Value>
          <Value Key="tipo" Passes="1" Type="String">[CallType]</Value>
          <Value Key="durata" Passes="1" Type="String">[Duration]</Value>
          <Value Key="telefono" Passes="1" Type="String">[Number]</Value>
          <Value Key="incarico" Passes="1" Type="String">[Agent]</Value>
          <Value Key="data" Passes="1" Type="String">[DateTime]</Value>
          <Value Key="start" Passes="1" Type="String">[CallStartTimeLocal]</Value>
          <Value Key="end" Passes="1" Type="String">[CallEndTimeLocal]</Value>
        </PostValues>
      </Request>
      <Variables />
      <Outputs AllowEmpty="true" />
    </Scenario>
  </Scenarios>
</Crm>
 
The definition of the EntityId and EntityOrder for the scenarios is wrong. Please check this for details:
https://www.3cx.com/docs/server-side-crm-template-xml-description/#h.h64uc9sz9soz

The EntityId should be the name of this entity. And the EntityOrder should specify the order of these entities separated by a slash (/). So, you should have this for your first scenario:
<Scenario Id="" Type="REST" EntityId="people" EntityOrder="people/factory">

And this for your second scenario:
<Scenario Id="" Type="REST" EntityId="factory" EntityOrder="people/factory">

If you see the standard 3CX templates, we use a parameter to define the order "people/factory" or "factory/people". You could use the same approach if you want this to be configured. If you want this hardcoded, then you have the option of specifying the order as I explained, or you can just put the scenarios in the desired order in the XML file.
 
  • Like
Reactions: Evolute IT
The definition of the EntityId and EntityOrder for the scenarios is wrong. Please check this for details:
https://www.3cx.com/docs/server-side-crm-template-xml-description/#h.h64uc9sz9soz

The EntityId should be the name of this entity. And the EntityOrder should specify the order of these entities separated by a slash (/). So, you should have this for your first scenario:
<Scenario Id="" Type="REST" EntityId="people" EntityOrder="people/factory">

And this for your second scenario:
<Scenario Id="" Type="REST" EntityId="factory" EntityOrder="people/factory">

If you see the standard 3CX templates, we use a parameter to define the order "people/factory" or "factory/people". You could use the same approach if you want this to be configured. If you want this hardcoded, then you have the option of specifying the order as I explained, or you can just put the scenarios in the desired order in the XML file.
Thanks for your reply, I make the changes indicated.
Best regards
 
  • Like
Reactions: edossantos
Status
Not open for further replies.

Latest Posts

Forum statistics

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