get array to variable (crm integration)

Status
Not open for further replies.

cberni

New User
Joined
Dec 24, 2020
Messages
32
Reaction score
2
----------------------

[
{
"id": "1366443957",
"codeReferenceAdditional": null,
"isActive": true,
"contacts": [
{
"contactType": "cellphone",
"contact": "484520",
"isDefault": true
},
{
"contactType": "Ramal",
"contact": "2000",
"isDefault": false
}
],
}
]

-------------

<Variables>
<Variable Name="ContactID" Path="id">
<Filter />
</Variable>
<Variable Name="LastName" Path="businessName">
<Filter />
</Variable>
<Variable Name="PhoneMobile" Path="contacts[0].contact">
<Filter />
</Variable>
</Variables>

-------------

"id" and "businessName" works fine. but "contacts[0].contact" don't.

how could I get the contact inside contacts?
is there a way to get the contat that isDefault = true?
 
did not work... in attach file please
 

Attachments

  • Captura de tela 2021-01-14 182921.png
    Captura de tela 2021-01-14 182921.png
    270.7 KB · Views: 15
Can you show the final template after applying the changes I suggested?
 
sure....

<?xml version="1.0"?>
<Crm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Country="BR" Name="Movidesk" Version="1">
<Number Prefix="AsIs" MaxLength="[MaxLength]" />
<Connection MaxConcurrentRequests="2" />
<Parameters>
<Parameter Name="Token" Type="String" Editor="String" Title="Movidesk Token" Default="" />
<Parameter Name="ReportCallEnabled" Type="Boolean" Editor="String" Title="Enable Call Journaling" Default="False" />
<Parameter Name="Subject" Type="String" Parent="ReportCallEnabled" Editor="String" Title="Call Subject:" Default="3CX PhoneSystem Call" />
<Parameter Name="InboundCallText" Type="String" Parent="ReportCallEnabled" Editor="String" Title="Answered Inbound Call:" Default="[DateTime]: Answered incoming call from [Number] to [Agent] ([Duration])" />
<Parameter Name="MissedCallText" Type="String" Parent="ReportCallEnabled" Editor="String" Title="Missed Call:" Default="[DateTime]: Missed call from [Number] to [Agent]" />
<Parameter Name="OutboundCallText" Type="String" Parent="ReportCallEnabled" Editor="String" Title="Answered Outbound Call:" Default="[DateTime]: Answered outgoing call from [Agent] to [Number] ([Duration])" />
<Parameter Name="NotAnsweredOutboundCallText" Type="String" Parent="ReportCallEnabled" Editor="String" Title="Unanswered Outbound Call:" Default="[DateTime]: Unanswered outgoing call from [Agent] to [Number]" />
</Parameters>
<Authentication Type="No" />
<Scenarios>
<Scenario Id="" Type="REST">
<Request Url="https://api.movidesk.com/public/v1/persons?token=[Token]&amp;$filter=Contacts/any(e: e/contact eq '[Number]')" MessagePasses="0" RequestEncoding="UrlEncoded" RequestType="Get" ResponseType="Json" />
<Rules>
<Rule Type="Any">id</Rule>
</Rules>
<Variables>
<Variable Name="ContactID" Path="id">
<Filter />
</Variable>
<Variable Name="LastName" Path="businessName">
<Filter />
</Variable>
<Variable Name="PhoneBusiness" Path="contacts.contact">
<Filter>
<Rule Type="Equals" Ethalon="true">contacts.isDefault</Rule>
</Filter>
</Variable>
</Variables>
<Outputs AllowEmpty="false">
<Output Type="ContactID" Passes="0" Value="[ContactID]" />
<Output Type="LastName" Passes="0" Value="[LastName]" />
<Output Type="PhoneBusiness" Passes="0" Value="[PhoneBusiness]" />
<Output Type="ContactUrl" Passes="0" Value="https://api.movidesk.com/public/v1/persons?token=[Token]&amp;id=[ContactID]" />
</Outputs>
</Scenario>
<Scenario Id="ReportCall" Type="REST">
<Request SkipIf="[ReportCallEnabled]!=True||[CallType]!=Inbound" Url="https://api.movidesk.com/public/v1/asterisk_startTransferedCall?token=[Token]&amp;queueId=1&amp;clientNumber=484520&amp;id=12345&amp;branchLine=2000&amp;callDate=2021-1-14T16:00:00&amp;transferDate=2021-1-12T16:02:00" MessagePasses="0" RequestEncoding="UrlEncoded" RequestType="Get" ResponseType="Json">
</Request>
<Variables />
<Outputs Next="ReportCallMissed" AllowEmpty="true" />
</Scenario>
<Scenario Id="ReportCallMissed" Type="REST">
<Request SkipIf="[ReportCallEnabled]!=True||[CallType]!=Missed" Url="" MessagePasses="0" RequestEncoding="UrlEncoded" RequestType="Get" ResponseType="Json">
</Request>
<Variables />
<Outputs Next="ReportCallOutbound" AllowEmpty="true" />
</Scenario>
<Scenario Id="ReportCallOutbound" Type="REST">
<Request SkipIf="[ReportCallEnabled]!=True||[CallType]!=Outbound" Url="" MessagePasses="0" RequestEncoding="UrlEncoded" RequestType="Get" ResponseType="Json">
</Request>
<Variables />
<Outputs Next="ReportCallNotanswered" AllowEmpty="true" />
</Scenario>
<Scenario Id="ReportCallNotanswered" Type="REST">
<Request SkipIf="[ReportCallEnabled]!=True||[CallType]!=Notanswered" Url="" MessagePasses="0" RequestEncoding="UrlEncoded" RequestType="Get" ResponseType="Json">
</Request>
<Variables />
<Outputs AllowEmpty="false" />
</Scenario>
</Scenarios>
</Crm>
 
Just for testing, can you change the filter to this?
<Rule Type="Equals" Ethalon="cellphone">contacts.contactType</Rule>

I want to see if the boolean value instead of a string is a problem for the filter matching.
 
same problem...

seens contacts.contact don't get value. If I take "Filter" off don't set contacts.contact value neither.
 
Made a test using a mock server that returns always the JSON you posted here. And managed to match the phone number. The problem is the case of the "isDefault" property, you need to compare it to "True" and not "true":
1610725255748.png

This is due to how the boolean is converted to a string in C#. So, the filter should be:
XML:
<Variable Name="PhoneBusiness" Path="contacts.contact">
    <Filter>
        <Rule Type="Equals" Ethalon="True">contacts.isDefault</Rule>
    </Filter>
</Variable>

That worked for me. Please advise.
 
  • Like
Reactions: cberni
it works! thanks a lot!
 
  • Like
Reactions: edossantos
Status
Not open for further replies.

Latest Posts

Forum statistics

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