Custom Function using SearchRecords API and associating to related list.

Custom Function using SearchRecords API and associating to related list.

Hi,

I'm trying to use the following code (found on this very forum) and i'm trying to tweak it for what our company needs.

What I want this custom function to do is search leads in our system by address using the searchRecords api with the criteria being the street address. After this, it associates the found leads to our related list "Leads".

I'm getting an error on the respMap line. I think this is what is causing the problem.

Any help greatly appreciated..

void SearchLeads (string streetId){
authtoken = "xxx";
respMap = getUrl("https://crm.zoho.com/crm/private/xml/Leads/searchRecords?authtoken=" + authtoken + "&scope=crmapi&criteria=(street:" + streetId + ")";
leadDetails = respMap.executeXPath("/crm/private/xml/Leads/searchRecords").toList("-|-");
countVal = 0;
paramsmap=map();
paramsmap.put("authtoken",authtoken);
paramsmap.put("scope","crmapi");
paramsmap.put("relatedModule","Leads");
test = "<Leads>";
for each item in leadDetails
{
countVal = countVal + 1;
leadIdStr = item.executeXPath("/lead/FL[@val ='LEADID']/text()");
info leadIdStr;
leadId = productIdStr.toLong();
test = test + "<row no=\""+countVal+"\">";
test = test + "<FL val=\"LEADID\">" + leadId + "</FL>";
test = test + "</row>";
}
test = test + "</Leads>";
paramsmap.put("xmlData", test);
info url;
}