Branching Statements

Branching Statements

Return Type: Return type is the data type specifier of the data returned by the function. If no data is returned by the function, the return type must be specified as void.

Example 1: For AddRelatedList

string getMySaasuData(string email)
{
contactResp =
getUrl("https://secure.saasu.com/webservices/rest/r1/ContactList?wsaccesskey=
CA497&fileuid=37863&SearchFieldName=EmailAddress&searchfieldnamebeginswith="
+ input.email);
contactStr = contactResp.executeXPath("/contactListResponse/contactList/contactListItem");
responseXML="";
lastModifiedTime='01-Jan-1901 00:00:00';
contactId="";
rowCount=1;
if((contactStr  !=  null)  &&  (contactStr  !=  ""))
{
responseXML="";
contactList=contactStr.toList("-|-");
for each contact in contactList
{
time=(contact.executeXPath("/contactListItem/utcLastModified/text()")).replaceAll("T"," ");
dt=time.toTime("yyyy-MM-dd hh:mm:ss");
if(dt  >  lastModifiedTime)
{
lastModifiedTime=dt;
contactId = contact.executeXPath("/contactListItem/contactUid/text()");
}
}
resp =
getUrl("https://secure.saasu.com/webservices/rest/r1/invoicelist?wsaccesskey=CA497&fileuid=37863
&transactiontype=s&contactUid="
+ contactId);
invoicesList=resp.executeXPath("/invoiceListResponse/invoiceList/invoiceListItem").toList("-|-");
info "invoicesList ::: " + invoicesList;
for each invoice in invoicesList
{
invoiceUID = invoice.executeXPath("/invoiceListItem/invoiceUid/text()");
invoiceNumber = invoice.executeXPath("/invoiceListItem/invoiceNumber/text()");
invoiceDate = invoice.executeXPath("/invoiceListItem/invoiceDate/text()");
dueDate = invoice.executeXPath("/invoiceListItem/dueDate/text()");
totalAmount = invoice.executeXPath("/invoiceListItem/totalAmountInclTax/text()");
responseXML=responseXML + "";
responseXML=responseXML + "" + invoiceUID + "";
responseXML=responseXML + "" + invoiceNumber + "";
responseXML=responseXML + "" + invoiceDate + "";
responseXML=responseXML + "" + dueDate + "";
responseXML=responseXML + "" + totalAmount + "";
responseXML=responseXML + "";
rowCount=(rowCount  +  1);
}
responseXML=responseXML + "
}
else
{
responseXML=responseXML + "";
responseXML=responseXML + "No Invoices found for this Contact";
responseXML=responseXML + "";
}
return responseXML; }

The custom function mentioned above will return an xml response in a tabular form.

Example2: For CustomButton

string Untitled_Function35 (map potential)
{
acquisitionDealId=input.potential.get("POTENTIALID");
potDetails = zoho.crm.getRecordById("Ptentials",acquisitionDealId.toLong());
potName=potDetails.get("Potential Name");
currency=potDetails.get("Currency");
mp=map();
mp.put("Subject",potName + " - Follow Up");
mp.put("SEID",acquisitionDealId);
mp.put("SEMOUDLE","Potentials");
mp.put("Currency",currency);
createresp=zoho.crm.create("Tasks",mp);
return "Task Created Successfully";
}

Share this post :

FacebookTwitter

Still can't find what you're looking for?

Write to us: support@zohodeveloper.com