Reputation: 11
** I am trying to open url mention in openURL funtion in Zoho crm usig deluge but not able to succeed. **
toReturn = "";
criteria = "Phone:equals:".concat(phone_number.toString());
response = zoho.crm.searchRecords(module,criteria);
if(1 < response.size())
{
toReturn = "Ambiguous";
}
else if(0 == response.size())
{
toReturn = "None";
}
else
{
toReturn = response.get(0).get("Full_Name");
openUrl("https://crm.zoho.in/crm/org60010034102/tab/Leads/" + response.get(0).get("id"),"same window");
}
info toReturn;
Upvotes: 1
Views: 1405
Reputation: 371
First thing. Did you try info response;
?
If its an OK response then this should work, but if its an error 1 < response.size()
will be triggered because errors have a size of 4. Try this or enter some invalid module name:
err_sample = {"code":"INVALID_MODULE","details":{},"message":"the module name given seems to be invalid","status":"error"};
info err_sample.size();
To handle success and error in this case you need to do something like this:
if (!isEmpty(response) && isNull(response.get(0)) && !isNull(response.get("code"))) {
// handle error
}
if (!isEmpty(response) && !isNull(response.get(0)) && !isNull(response.get(0).get("id"))) {
// handle success
}
If its just a matter of the url failing to open when you click 'Save & Execute' in the Function editor, I don't think you can do this from the code editor. I've tried a bunch of different ways and I could not get a url to open. If not, how is the function being called?
Upvotes: 1