<div dir="ltr">Ahhh , Ok . <div>Now it's very complicated . When you said a loop that's looping in my mind . Sorry for the bad joke . </div><div><br></div><div>In case , the number of elements in each Invite won't be fixed . So the number of loops will vary from one Invite to another . </div><div>I was thinking of counting the number of elements first , then as the index starts from 0 I will loop till <b>count-1</b> to fetch every element properly . </div><div><br></div><div>Example : </div><div>$var(count) = $(hdr(Call-Info){csv.count}) ## if the number is 3 then loop will be for 3 times starting from 0 to 2 </div><div><br></div><div> $var(i) = 0;<br> while($var(i) < $var(count) )<br> {<br> xlog("counter: $var(i)\n");<br> $var(i) = $var(i) + 1;<br> }</div><div><br></div><div>This was my initial thought . But while finding the count it gave me an error . <b> $var(count) = $(hdr(Call-Info){csv.count}) Is this not in the correct format ? </b></div><div><b><br></b></div><div><b>parse error in /usr/local/etc/opensips/opensips-p2p.cfg:267:26-55: unknown script variable</b></div><div><b><br></b></div><div><b>As I have earlier mentioned my header will look like . </b></div><div><b>Call-Info: sales,en,level20,en (this can be anything but format will be like this . ) . How do I count the number of values ?</b></div><div><b><br></b></div><div><b>2. As I am doing this matching to filter out contacts, where should I do this ? If I am doing this while giving a call to the contacts , for the 1st transaction it is doing the comparison , after that for the next branch it processes the call without matching . Which is not right . For every contact this comparison should loop </b></div><div><b><br clear="all"></b><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><b><i>Thanks & Regards</i></b><div><i>Sasmita Panda</i></div><div><i>Senior Network Testing and Software Engineer</i></div><div><i>3CLogic , ph:07827611765</i></div></div></div></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Oct 26, 2023 at 7:19 PM Ben Newlin <<a href="mailto:Ben.Newlin@genesys.com">Ben.Newlin@genesys.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="msg-9030004461135996846">
<div lang="EN-US" style="overflow-wrap: break-word;">
<div class="m_-8817526463220756066WordSection1">
<p class="MsoNormal"><span style="font-size:11pt">Sasmita,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt">Apologies, I replied yesterday but the message is being held by the list as the quoted replies have made it too large. I’ve removed some of the quoted replies and I’m copying my response below:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt">Yes, a substring match means the exact complete string exists somewhere in the string being searched . In your example, the $avp(attr) does not contain any substring that matches $hdr(Call-Info), so it is
correctly failing.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt"> <u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt">If you want to check for the presence of each element, you need to loop through the elements in $hdr(Call-Info) and check for each one in the $avp(attr) using the s.index mechanism.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt"> <u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt">The best options for looping on the header are probably s.select [1] or the csv tranformations [2].<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt"> <u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt">[1] <a href="https://www.opensips.org/Documentation/Script-Tran-3-2#toc7" title="https://www.opensips.org/Documentation/Script-Tran-3-2#toc7" target="_blank">https://www.opensips.org/Documentation/Script-Tran-3-2#toc7</a><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt">[2] <a href="https://www.opensips.org/Documentation/Script-Tran-3-2#toc82" title="https://www.opensips.org/Documentation/Script-Tran-3-2#toc82" target="_blank">https://www.opensips.org/Documentation/Script-Tran-3-2#toc82</a><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;color:black">Ben Newlin</span><span style="font-size:11pt"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt"><u></u> <u></u></span></p>
<div id="m_-8817526463220756066mail-editor-reference-message-container">
<div>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(181,196,223);padding:3pt 0in 0in">
<p class="MsoNormal" style="margin-bottom:12pt"><b><span style="font-size:12pt;font-family:Aptos,sans-serif;color:black">From:
</span></b><span style="font-size:12pt;font-family:Aptos,sans-serif;color:black">Users <<a href="mailto:users-bounces@lists.opensips.org" target="_blank">users-bounces@lists.opensips.org</a>> on behalf of Sasmita Panda <<a href="mailto:spanda@3clogic.com" target="_blank">spanda@3clogic.com</a>><br>
<b>Date: </b>Thursday, October 26, 2023 at 8:46 AM<br>
<b>To: </b>OpenSIPS users mailling list <<a href="mailto:users@lists.opensips.org" target="_blank">users@lists.opensips.org</a>><br>
<b>Subject: </b>Re: [OpenSIPS-Users] I need some help in attr matching while forming the Branch .<u></u><u></u></span></p>
</div>
<div>
<div>
<div>
<table border="1" cellspacing="0" cellpadding="0" style="border-collapse:collapse;border:none">
<tbody>
<tr>
<td style="border:1pt solid rgb(182,0,0);background:white;padding:0.75pt">
<p class="MsoNormal"><b><span style="font-size:12pt;color:rgb(182,0,0)"> EXTERNAL EMAIL - Please use caution with links and attachments <u></u><u></u></span></b></p>
</td>
</tr>
</tbody>
</table>
</div>
<p class="MsoNormal"><span style="font-size:9pt;font-family:Helvetica;color:black"><u></u> <u></u></span></p>
<div class="MsoNormal" align="center" style="text-align:center"><span style="font-size:11pt">
<hr size="0" width="100%" align="center">
</span></div>
</div>
<p class="MsoNormal"><span style="font-size:11pt">Is there any update on this ? <u></u><u></u></span></p>
</div>
<p class="MsoNormal"><span style="font-size:11pt"><u></u> <u></u></span></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11pt">On Wed, 25 Oct 2023, 19:27 Sasmita Panda, <</span><a href="mailto:spanda@3clogic.com" target="_blank"><span style="font-size:11pt">spanda@3clogic.com</span></a><span style="font-size:11pt">> wrote:<u></u><u></u></span></p>
</div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0in 0in 0in 6pt;margin:5pt 0in 5pt 4.8pt">
<div>
<p class="MsoNormal"><span style="font-size:11pt">Hi Ben , <u></u><u></u></span></p>
<div>
<p class="MsoNormal"><span style="font-size:11pt"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt">Please correct me if I am wrong . <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><b><span style="font-size:11pt">$avp(attr) : sales,level20,en,true</span></b><span style="font-size:11pt"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><b><span style="font-size:11pt">$hdr(Call-Info) : sales,en</span></b><span style="font-size:11pt"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><b><span style="font-size:11pt"> if ($(avp(attr){s.index, $hdr(Call-Info)}) != NULL)<br>
{<br>
xlog("found $hdr(Call-Info) in $avp(attr) \n");<br>
if (next_branches()){<br>
t_on_failure("1");<br>
}<br>
}<br>
else {<br>
sl_send_reply(500,"Unable to load contacts");<br>
exit;<br>
<br>
}</span></b><span style="font-size:11pt"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt">In this case , although $hdr(Call-Info) is a substring of $avp(attr) still it's going in the else block and giving me
<b>500 Unable to load contacts</b> . <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt">Does the substring must contain continuous values ? <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt"><u></u> <u></u></span></p>
</div>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal"><b><i><span style="font-size:11pt">Thanks & Regards</span></i></b><span style="font-size:11pt"><u></u><u></u></span></p>
<div>
<p class="MsoNormal"><i><span style="font-size:11pt">Sasmita Panda</span></i><span style="font-size:11pt"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><i><span style="font-size:11pt">Senior Network Testing and Software Engineer</span></i><span style="font-size:11pt"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><i><span style="font-size:11pt">3CLogic , ph:07827611765</span></i><span style="font-size:11pt"><u></u><u></u></span></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</div>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
</div></blockquote></div>