CRM Call Journaling by Specific Agent

ReeceWallace

Platinum Partner
Advanced Certified
Joined
Nov 20, 2019
Messages
25
Reaction score
10
Hi,

I am experiencing an issue in which I can't get my Agent lookup to work appropriately with the CRM.

If the agent email searches and returns a UserId, it should journal as that agent in the CRM (Working)
if the agent email is searched and returns no Userid, it should skip that part of the journaling (Not working)

Instead, if there is no match, it fails to journal due to an empty string, can anyone assist? XML Below

<Scenario Id="ReportCall" Type="REST">
<Request SkipIf="[IIf([ReportCallEnabled]!=True||[EntityId]==&quot;&quot;,True,False)]" Url="[restUrl]query/CorporateUser?where=email='[AgentEmail]'&amp;fields=id,name,email&amp;count=500" MessagePasses="0" RequestEncoding="UrlEncoded" RequestType="Get" ResponseType="Json" >
<Headers>
<Value Key="BhRestToken">[BhRestToken]</Value>
</Headers>
</Request>
<Rules>
<Rule Type="Any">data.id</Rule>
</Rules>
<Variables>
<Variable Name="UserId" Path="data.id"><Filter /></Variable>
</Variables>
<Outputs Next="CreateCallActivity" AllowEmpty="true" />
</Scenario>
<Scenario Id="CreateCallActivity" Type="REST">
<Request SkipIf="[IIf([ReportCallEnabled]!=True||[EntityId]==&quot;&quot;,True,False)]" Url="[restUrl]entity/Note" MessagePasses="0" RequestEncoding="Json" RequestType="Put" ResponseType="Json" >
<Headers>
<Value Key="BhRestToken">[BhRestToken]</Value>
</Headers>
<PostValues>
<Value Key="comments" If="[CallType]==Inbound" Passes="2" Type="String">[[InboundCallText]]</Value>
<Value Key="comments" If="[CallType]==Missed" Passes="2" Type="String">[[MissedCallText]]</Value>
<Value Key="comments" If="[CallType]==Outbound" Passes="2" Type="String">[[OutboundCallText]]</Value>
<Value Key="comments" If="[CallType]==Notanswered" Passes="2" Type="String">[[NotAnsweredOutboundCallText]]</Value>
<Object Key="personReference">
<Value Key="id" Passes="2" Type="Integer">[[EntityId]]</Value>
</Object>
<Object Key="commentingPerson" SkipIf="[UserId]==&quot;&quot;">
<Value Key="id" Passes="2" Type="Integer">[[UserId]]</Value>
</Object>
<Value Key="action" If="[CallType]==Inbound" Type="String">Inbound Answered Call</Value>
<Value Key="action" If="[CallType]==Missed" Type="String">Inbound Missed Call</Value>
<Value Key="action" If="[CallType]==Outbound" Type="String">Outbound Answered Call</Value>
<Value Key="action" If="[CallType]==Notanswered" Type="String">Outbound Missed Call</Value>
<Value Key="minutesSpent" If="[IIf([CallType]==Inbound||[CallType]==Outbound,True,False)]" Passes="2" Type="Integer">[[[DurationTimespan].get_TotalSeconds()].ToString("F0")]</Value>
</PostValues>
</Request>
</Scenario>
 
Change this:
<Outputs Next="CreateCallActivity" AllowEmpty="true" />

to:
<Outputs Next="CreateCallActivity" AllowEmpty="false" />

This way the next scenario will not be executed if the previous one didn't provide an output.
 
Ah but I still want the next scenario to execute. It will still journal without the Commenting Person as a default user. But I can't get it to skip the commenting person entry if the UserId is not found
 
Ah, got it. The SkipIf is wrong there, you have the If attribute instead. So, you should change:
<Object Key="commentingPerson" SkipIf="[UserId]==&quot;&quot;">

to:
<Object Key="commentingPerson" If="[UserId]!=&quot;&quot;">
 
That was it!

Was there a reason SkipIf wouldn't work here? or is If statements only recognised in the Post Values entries?