This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

The first use case in the  ActiveCollab business scenario is project initiation, in which you retrieve contacts and potentials won from ZohoCRM and use that data to create clients and projects in ActiveCollab. This page describes these tasks and the operations you use in the ActiveCollab and ZohoCRM connectors. 

Overview

The flow for project initiation is illustrated in the following diagram. We will use the ESB connectors for ActiveCollab and ZohoCRM to connect to each service. 

Inline image 3

  1. Retrieve the relevant contact information from ZohoCRM using getRecords  to identify the latest records (e.g., those that were modified since yesterday) and getRecordById to retrieve details of the contact you want.

  2. Create the client in ActiveCollab using createClient. You can use listCompanies to identify the contact's account name in ZohoCRM, which should be mapped to the company name in ActiveCollab. If the ZohoCRM contact's account name is not matched to an existing ActiveCollab company name, the client creation operation is skipped for that contact.

    Request parameter description is as follows:

    • zohoApiUrl:  API URL of ZohoCRM.
    • zohoAccessToken: Access token for ZohoCRM.
    • zohoScope: ZohoCRM scope should be "crmapi".
    • zohoNewFormat: An integer used to specify whether to exclude (1) or include (2) fields with null values while inserting data from your CRM account.
    • zohoVersion: An integer used to specify the API version. A value of 1 will fetch responses based on the earlier API implementation. A value of 2 will fetch responses based on the latest API implementation. Default is 1.
    • activecollabApiUrl: API URL for ActiveCollab account.
    • activecollabApiToken: API Access token for ActiveCollab account user. User access level should be 'Read and Write' and not 'Read only'.
    • activecollabPassword: Password of the client account.
  3. Retrieve the potentials that were won in ZohoCRM using getRecords  to identify the latest records (e.g., those that were modified since yesterday) and getRecordById to retrieve details of the potential you want.
  4. Create projects in ActiveCollab using createProject. You can create projects in ActiveCollab from clients and potentials in ZohoCRM. Again, the ZohoCRM contact's account name must be matched to an existing ActiveCollab company name.

    Request parameter description is as follows:

    • zohoApiUrl:  API URL of ZohoCRM.
    • zohoAccessToken: Access token for ZohoCRM.
    • zohoScope: ZohoCRM scope should be "crmapi".
    • zohoNewFormat: An integer used to specify whether to exclude (1) or include (2) fields with null values while inserting data from your CRM account.
    • zohoVersion: An integer used to specify the API version. A value of 1 will fetch responses based on the earlier API implementation. A value of 2 will fetch responses based on the latest API implementation. Default is 1.
    • activecollabApiUrl: API URL for ActiveCollab account.
    • activecollabApiToken: API Access token for ActiveCollab account user. User access level should be 'Read and Write' and not 'Read only'.

     

Zoho CRM operations
ActiveCollab operations

Samples

Sample template for retrieving contact details using contactId and creating client
<!-- This template retrieves Contact details from ZohoCRM using contactId and then creates Client in ActiveCollab -->
<template xmlns="http://ws.apache.org/ns/synapse" name="activecollab-retrieveContactAndCreateClient">
   <parameter name="zohoApiUrl" description="The Zoho API URL."/>
   <parameter name="zohoAccessToken" description="Encrypted alphanumeric string to authenticate the Zoho credentials." />
   <parameter name="zohoScope" description="Zoho CRM scope. Specify the value as crmapi."/>
   <parameter name="zohoContactId" description="Zoho contact ID, which is required to create client. "/>
   <parameter name="zohoNewFormat" description="Whether null values should be excluded (1) or included (2)." />
   <parameter name="zohoVersion" description="The API version."/>
   <parameter name="activecollabApiToken" description="Encrypted alphanumeric string to authenticate the ActiveCollab credentials."/>
   <parameter name="activecollabApiUrl" description="The ActiveCollab API URL."/>
   <parameter name="activecollabPassword" description="The password for the ActiveCollab client account."/>
   <sequence>
      
		<property name="uri.var.zohoApiUrl" expression="$func:zohoApiUrl" />
		<property name="uri.var.zohoAccessToken" expression="$func:zohoAccessToken" />
		<property name="uri.var.zohoScope" expression="$func:zohoScope" />
		<property name="uri.var.zohoContactId" expression="$func:zohoContactId" />
		<property name="uri.var.zohoNewFormat" expression="$func:zohoNewFormat" />
		<property name="uri.var.zohoVersion" expression="$func:zohoVersion" />
		<property name="uri.var.activecollabApiToken" expression="$func:activecollabApiToken" />
		<property name="uri.var.activecollabApiUrl" expression="$func:activecollabApiUrl" />
		<property name="uri.var.activecollabPassword" expression="$func:activecollabPassword" />
      
		<!-- Retrieve Contact details from ZohoCRM -->
		<zohocrm.init>
			<apiUrl>{$ctx:uri.var.zohoApiUrl}</apiUrl>
			<accessToken>{$ctx:uri.var.zohoAccessToken}</accessToken>
			<scope>{$ctx:uri.var.zohoScope}</scope>
		</zohocrm.init>
		<zohocrm.getRecordsById>
			<id>{$ctx:uri.var.zohoContactId}</id>
			<newFormat>{$ctx:uri.var.zohoNewFormat}</newFormat>
			<version>{$ctx:uri.var.zohoVersion}</version>
			<moduleType>Contacts</moduleType>
		</zohocrm.getRecordsById>
	 
		<property name="uri.var.contactAttributes" expression="json-eval($.response.result.Contacts.row.FL)" />
	  
		<!-- Extract required parameters from ZohoCRM getRecordsById response -->
		<script language="js">var jsn = eval("(" + mc.getProperty("uri.var.contactAttributes") + ")");
        		
			for (var i = 0; i &lt; jsn.length ; i++) {
					
				if(jsn[i].val == "Email"){
						mc.setProperty('uri.var.activecollabEmail', jsn[i].content);
				}else if(jsn[i].val == "First Name"){
						mc.setProperty('uri.var.activecollabFirstName', jsn[i].content);
				}else if(jsn[i].val == "Last Name"){
						mc.setProperty('uri.var.activecollabLastName', jsn[i].content);
				}else if(jsn[i].val == "Phone"){
						mc.setProperty('uri.var.activecollabPhoneWork', jsn[i].content);
				}else if(jsn[i].val == "Mobile"){
						mc.setProperty('uri.var.activecollabPhoneMobile', jsn[i].content);
				}else if(jsn[i].val == "Title"){
						mc.setProperty('uri.var.activecollabTitle', jsn[i].content);
				}else if(jsn[i].val == "Account Name"){
						mc.setProperty('uri.var.zohoAccountName', jsn[i].content);
				}
				
			}</script>
		<filter source="boolean(get-property('uri.var.activecollabApiToken'))" regex="true">
			<then>
				<!-- Calling activecollab-getCompanyIdByZohoAccountName template to validate ActiveCollab company name against ZohoCRM account name and retrieve ActiveCollab Company ID -->
				<call-template target="activecollab-getCompanyIdByZohoAccountName">
					<with-param name="activecollabApiUrl" value="{$ctx:uri.var.activecollabApiUrl}" />
					<with-param name="activecollabApiToken" value="{$ctx:uri.var.activecollabApiToken}" />
					<with-param name="zohoAccountName" value="{$ctx:uri.var.zohoAccountName}" />
				</call-template>
			  
				<!-- Validate ActiveCollab Company ID -->
				<filter source="boolean(get-property('uri.var.activecollabCompanyId'))" regex="true">
					<then>
						<!-- Create ActiveCollab client using ZohoCRM contact details -->
						<activecollab.init>
						   <apiUrl>{$ctx:uri.var.activecollabApiUrl}</apiUrl>
						   <apiToken>{$ctx:uri.var.activecollabApiToken}</apiToken>
						   <format>json</format>
						</activecollab.init>
						<activecollab.createClient>
						   <lastName>{$ctx:uri.var.activecollabLastName}</lastName>
						   <passwordRepeat>{$ctx:uri.var.activecollabPassword}</passwordRepeat>
						   <type>Client</type>
						   <password>{$ctx:uri.var.activecollabPassword}</password>
						   <phoneWork>{$ctx:uri.var.activecollabPhoneWork}</phoneWork>
						   <title>{$ctx:uri.var.activecollabTitle}</title>
						   <phoneMobile>{$ctx:uri.var.activecollabPhoneMobile}</phoneMobile>
						   <email>{$ctx:uri.var.activecollabEmail}</email>
						   <companyId>{$ctx:uri.var.activecollabCompanyId}</companyId>
						   <firstName>{$ctx:uri.var.activecollabFirstName}</firstName>
						</activecollab.createClient>
						
						<property name="uri.var.activecollabClientId" expression="json-eval($.id)" />
						
						<!-- Verify ActiveCollab Client is created -->
						<filter source="boolean(get-property('uri.var.activecollabClientId'))" regex="true">
						   <then>
								<property name="uri.var.status" value="Success" />
								<property name="uri.var.message" expression="fn:concat('Client created successfully with the Client ID ',get-property('uri.var.activecollabClientId'),' .')" />
						   </then>
						   <else>
								<property name="uri.var.status" value="Error" />
								<property name="uri.var.message" expression="json-eval($.)" />
						   </else>
						</filter>
						
					</then>
					<else>
						<property name="uri.var.status" value="Error" />
						<property name="uri.var.message" expression="fn:concat('Could not find Account name ',get-property('uri.var.zohoAccountName'),' in Activecollab.')" />
						
					</else>
			  </filter>
			</then>
			<else>
				<property name="uri.var.status" value="Skipped" />
				<property name="uri.var.message" value="ActiveCollab API Token not provided."/>
			</else>
		</filter>
		
		<property name="uri.var.id" expression="fn:concat('contact_id:',get-property('uri.var.zohoContactId'))" />
		<call-template target="responseHandlerTemplate">
			<with-param name="id" value="{$ctx:uri.var.id}" />
			<with-param name="status" value="{$ctx:uri.var.status}" />
			<with-param name="message" value="{$ctx:uri.var.message}" />
		</call-template>
   </sequence>
</template>
Sample template for validating and retrieving ActiveCollab company ID against ZohoCRM account name
<!--This template validates and retrieves ActiveCollab company ID against ZohoCRM Account name.-->
<template xmlns="http://ws.apache.org/ns/synapse"
          name="activecollab-getCompanyIdByZohoAccountName">
   <parameter name="activecollabApiUrl" description="The ActiveCollab API URL."/>
   <parameter name="activecollabApiToken" description="Encrypted alphanumeric string to authenticate the ActiveCollab credentials."/>
   <parameter name="zohoAccountName" description="The ZohoCRM account name."/>
   
   <sequence>
      <property name="uri.var.activecollabApiUrl"
                expression="$func:activecollabApiUrl"/>
      <property name="uri.var.activecollabApiToken"
                expression="$func:activecollabApiToken"/>
      <property name="uri.var.zohoAccountName"
                expression="$func:zohoAccountName"/>
	 
     
      <activecollab.init>
         <apiUrl>{$ctx:uri.var.activecollabApiUrl}</apiUrl>
         <apiToken>{$ctx:uri.var.activecollabApiToken}</apiToken>
         <format>json</format>
      </activecollab.init>
      <activecollab.listCompanies/>
	 
		<script language="js">
			var companies = mc.getPayloadJSON();
			var zohoAccountName = mc.getProperty("uri.var.zohoAccountName");
			
			for(var i = 0; i &lt; companies.length ; i++ ){
				var company=companies[i];
				
				
				if(company.name == zohoAccountName){
					mc.setProperty('uri.var.activecollabCompanyId',""+company.id);
					
					
				}
				
			}
		</script>
	</sequence>
</template>
Sample proxy for creating ActiveCollab clients
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="activeCollab_retrieveContactAndCreateClient"
       transports="https http"
       startOnLoad="true"
       trace="disable">
   <description/>
   <target>
      <inSequence onError="faultHandlerSeq">
         <property name="zohoApiUrl" expression="json-eval($.zohoApiUrl)"/>
         <property name="zohoAccessToken" expression="json-eval($.zohoAccessToken)"/>
         <property name="zohoScope" expression="json-eval($.zohoScope)"/>
         <property name="zohoNewFormat" expression="json-eval($.zohoNewFormat)"/>
         <property name="zohoVersion" expression="json-eval($.zohoVersion)"/>
         <property name="activecollabApiUrl" expression="json-eval($.activecollabApiUrl)"/>
         <property name="activecollabApiToken"
                   expression="json-eval($.activecollabApiToken)"/>
         <property name="activecollabPassword"
                   expression="json-eval($.activecollabPassword)"/>
		<property name="index" value="0" scope="operation"/>
		<property name="responseString" value="" scope="operation"/>
		
		<!-- Retrieve all contacts from ZohoCRM -->
		<script language="js">
		 var currentDate=new Date();
		 var previousDate = new Date(currentDate.getFullYear(),currentDate.getMonth(),currentDate.getDate()-1);
		 var dateString=previousDate.getFullYear() + "-" + Number(previousDate.getMonth()+1) + "-" + previousDate.getDate() +" 00:00:00";
		 mc.setProperty('lastModifiedTime', dateString);
		 
		 </script>
         <zohocrm.init>
            <scope>{$ctx:zohoScope}</scope>
            <accessToken>{$ctx:zohoAccessToken}</accessToken>
            <apiUrl>{$ctx:zohoApiUrl}</apiUrl>
         </zohocrm.init>
         <zohocrm.getRecords>
            <newFormat>{$ctx:zohoNewFormat}</newFormat>
            <version>{$ctx:zohoVersion}</version>
            <moduleType>Contacts</moduleType>
			<lastModifiedTime>{$ctx:lastModifiedTime}</lastModifiedTime>
         </zohocrm.getRecords>
		 
		  
		 <property name="messageType" value="application/xml" scope="axis2"/>
		  
         <property name="contactsCount"
                   expression="count(//response/result/Contacts/row)"
                   scope="operation"/>
		<!-- Checking if there are any contacts to be processed, else skipping. -->	
		<filter xpath="0 != get-property('operation', 'contactsCount')">
			<then>
				<iterate continueParent="true"
                  id="contactIterator"
                  preservePayload="true"
                  expression="//response/result/Contacts/row"
                  sequential="true">
					<target>
						<sequence>
							
							<property name="zohoContactId" expression="//FL[1]/content/text()"/>
							<!-- Calling activecollab-retrieveContactAndCreateClient template to create Clients in ActiveCollab-->
							<call-template target="activecollab-retrieveContactAndCreateClient">
								<with-param name="zohoApiUrl" value="{$ctx:zohoApiUrl}"/>
								<with-param name="zohoAccessToken" value="{$ctx:zohoAccessToken}"/>
								<with-param name="zohoScope" value="{$ctx:zohoScope}"/>
								<with-param name="zohoContactId" value="{$ctx:zohoContactId}"/>
								<with-param name="zohoNewFormat" value="{$ctx:zohoNewFormat}"/>
								<with-param name="zohoVersion" value="{$ctx:zohoVersion}"/>
								<with-param name="activecollabApiToken" value="{$ctx:activecollabApiToken}"/>
								<with-param name="activecollabApiUrl" value="{$ctx:activecollabApiUrl}"/>
								<with-param name="activecollabPassword" value="{$ctx:activecollabPassword}"/>
								</call-template> 
							<property name="index" expression="get-property('operation','index') + 1" scope="operation"/>
						</sequence>
					</target>
				</iterate>
        
				<filter xpath="get-property('operation','index') = get-property('operation', 'contactsCount')" >
					<then>
						<loopback />
					</then>
				</filter>
					
			</then>
		<else>
					
			<property name="idParam" value=" " />
			<property name="status" value="Skipped" />
			<property name="message" value="No contacts were found." />
			
			<call-template target="responseHandlerTemplate">
				<with-param name="id" value="{$ctx:idParam}" />
				<with-param name="status" value="{$ctx:status}" />
				<with-param name="message" value="{$ctx:message}" />
			</call-template>
					
			<loopback />
		</else>
		</filter>	
	</inSequence>
    <outSequence>
        <property name="messageType" value="application/json" scope="axis2"/>
         
        
		<payloadFactory media-type="json">
            <format>
				{
				"Response":{
					"activity":"activecollab-retrieveContactAndCreateClient",
					"activityResponse":[$1]
				}
				}
			</format>
            <args>
				
                <arg evaluator="xml" expression="get-property('operation', 'responseString')"/>
            </args>
        </payloadFactory>
		
        <send/>
    </outSequence>
   </target>
</proxy>                                                                                  
Sample request for creating ActiveCollab clients
{
	"zohoApiUrl":"https://crm.zoho.com",
	"zohoAccessToken":"e6cbeb86661abf9922a0d95ccc9b124b",
	"zohoScope":"crmapi",
	"zohoNewFormat":"1",
	"zohoVersion":"1",
	"activecollabApiUrl":"https://virtusajpc.manageprojects.com",
	"activecollabApiToken":"1-JwWMlV9kjmeNJ1j4OPlm4CDUqdZ09QxHcjin6fye",
	"activecollabPassword":"123456"
	
}
Sample template for retrieving potential details from ZohoCRM using potentialId and creating project
<!-- This template retrieves Potential details form ZohoCRM using potentialId and then creates a Project in ActiveCollab -->
<template xmlns="http://ws.apache.org/ns/synapse"
          name="activecollab-retrievePotentialsAndInitiateProject">
		<parameter name="zohoApiUrl" description="The Zoho API URL."/>
		<parameter name="zohoAccessToken" description="Encrypted alphanumeric string to authenticate the Zoho credentials." />
		<parameter name="zohoScope" description="Zoho CRM scope. Specify the value as crmapi."/>
		<parameter name="zohoPotentialId" description="Zoho potential ID, which is required to create the project. "/>
		<parameter name="zohoNewFormat" description="Whether null values should be excluded (1) or included (2)." />
		<parameter name="zohoVersion" description="The Zoho API version."/>
		<parameter name="activecollabApiToken" description="Encrypted alphanumeric string to authenticate the ActiveCollab credentials."/>
		<parameter name="activecollabApiUrl" description="The ActiveCollab API URL."/>
   
   <sequence>
		<property name="uri.var.zohoApiUrl" expression="$func:zohoApiUrl"/>
        <property name="uri.var.zohoAccessToken" expression="$func:zohoAccessToken"/>
        <property name="uri.var.zohoScope" expression="$func:zohoScope"/>
        <property name="uri.var.zohoPotentialId" expression="$func:zohoPotentialId"/>
        <property name="uri.var.zohoNewFormat" expression="$func:zohoNewFormat"/>
        <property name="uri.var.zohoVersion" expression="$func:zohoVersion"/>
        <property name="uri.var.activecollabApiUrl" expression="$func:activecollabApiUrl"/>
        <property name="uri.var.activecollabApiToken"
                   expression="$func:activecollabApiToken"/>
        
          <!-- Retrieve Potentials details from ZohoCRM --> 
         <zohocrm.init>
            <apiUrl>{$ctx:uri.var.zohoApiUrl}</apiUrl>
            <accessToken>{$ctx:uri.var.zohoAccessToken}</accessToken>
            <scope>{$ctx:uri.var.zohoScope}</scope>
         </zohocrm.init>
         <zohocrm.getRecordsById>
            <id>{$ctx:uri.var.zohoPotentialId}</id>
            <newFormat>{$ctx:uri.var.zohoNewFormat}</newFormat>
            <version>{$ctx:uri.var.zohoVersion}</version>
            <moduleType>Potentials</moduleType>
         </zohocrm.getRecordsById>
		 
         
         <property name="uri.var.potentialsAttributes"
                   expression="json-eval($.response.result.Potentials.row.FL)"/>
        
		<!-- Extract required parameters from ZohoCRM Potentials response -->
         <script language="js">var jsn = eval("(" + mc.getProperty("uri.var.potentialsAttributes") + ")");
        		
			for (var i = 0; i &lt; jsn.length ; i++) {
						
				if(jsn[i].val == "Potential Name"){
						mc.setProperty('uri.var.activecollabProjectName', jsn[i].content);
				}else if(jsn[i].val == "Description"){
						mc.setProperty('uri.var.activecollabDescription', jsn[i].content);
				}else if(jsn[i].val == "Stage"){
						mc.setProperty('uri.var.zohoPotentialStage', jsn[i].content);
				}else if(jsn[i].val == "Account Name"){
						mc.setProperty('uri.var.zohoAccountName', jsn[i].content);
				}else if(jsn[i].val == "Amount"){
						mc.setProperty('uri.var.activecollabBudget', jsn[i].content);
				}
			}</script>
			<!-- Check ZohoCRM Potential stage -->
			<filter xpath="get-property('uri.var.zohoPotentialStage') != 'Closed Won' ">
				<then>
					<property name="uri.var.status" value="Error" />
					<property name="uri.var.message" value="Could not create project for this potential because it is not in Closed Won stage." />  
               
				</then>
				<else>
					<filter source="boolean(get-property('uri.var.activecollabApiToken'))" regex="true">
						<then>
							<!-- Calling activecollab-getCompanyIdByZohoAccountName template to validate and retrieve ActiveCollab company ID-->
							<call-template target="activecollab-getCompanyIdByZohoAccountName">
								<with-param name="activecollabApiUrl" value="{$ctx:uri.var.activecollabApiUrl}"/>
								<with-param name="activecollabApiToken" value="{$ctx:uri.var.activecollabApiToken}"/>
								<with-param name="zohoAccountName" value="{$ctx:uri.var.zohoAccountName}"/>
							</call-template>
			
							<filter source="boolean(get-property('uri.var.activecollabCompanyId'))" regex="true">
								<then>
									<!-- Create Activecollab project using ZohoCRM potential details -->
									<activecollab.init>
										<apiUrl>{$ctx:uri.var.activecollabApiUrl}</apiUrl>
										<apiToken>{$ctx:uri.var.activecollabApiToken}</apiToken>
										<format>json</format>
									</activecollab.init>
									<activecollab.createProject>
										<name>{$ctx:uri.var.activecollabProjectName}</name>
										<companyId>{$ctx:uri.var.activecollabCompanyId}</companyId>
										<overview>{$ctx:uri.var.activecollabDescription}</overview>
										<budget>{$ctx:uri.var.activecollabBudget}</budget>
									</activecollab.createProject>
									
									<property name="uri.var.activecollabProjectId" expression="json-eval($.id)" />
			
									<!-- Verify that ActiveCollab Project is created -->
									<filter source="boolean(get-property('uri.var.activecollabProjectId'))" regex="true">
									   <then>
											<property name="uri.var.status" value="success" />
											<property name="uri.var.message" expression="fn:concat('Project created successfully with the Project ID ',get-property('uri.var.activecollabProjectId'))" />
									   </then>
									   <else>
											<property name="uri.var.status" value="Error" />
											<property name="uri.var.message" expression="json-eval($.)" />
									   </else>
									</filter>
								</then>
								<else>
									<property name="uri.var.status" value="Error" />
									<property name="uri.var.message" expression="fn:concat('Could not find Account name ',get-property('uri.var.zohoAccountName'),' in ActiveCollab.')" />
								</else>
							</filter>
						</then>
						<else>
							<property name="uri.var.status" value="Skipped" />
							<property name="uri.var.message" value="ActiveCollab API Token not provided."/>
						</else>
					</filter>
				</else>
			</filter>
        <property name="uri.var.id" expression="fn:concat('potential_id:',get-property('uri.var.zohoPotentialId'))" />
		<call-template target="responseHandlerTemplate">
			<with-param name="id" value="{$ctx:uri.var.id}" />
			<with-param name="status" value="{$ctx:uri.var.status}" />
			<with-param name="message" value="{$ctx:uri.var.message}" />
		</call-template>
        
	</sequence>
</template>
Sample template for validating and retrieving ActiveCollab company ID against ZohoCRM account name
<!--This template validates and retrieves ActiveCollab company ID against ZohoCRM Account name.-->
<template xmlns="http://ws.apache.org/ns/synapse"
          name="activecollab-getCompanyIdByZohoAccountName">
   <parameter name="activecollabApiUrl" description="The ActiveCollab API URL."/>
   <parameter name="activecollabApiToken" description="Encrypted alphanumeric string to authenticate the ActiveCollab credentials."/>
   <parameter name="zohoAccountName" description="The ZohoCRM account name."/>
   
   <sequence>
      <property name="uri.var.activecollabApiUrl"
                expression="$func:activecollabApiUrl"/>
      <property name="uri.var.activecollabApiToken"
                expression="$func:activecollabApiToken"/>
      <property name="uri.var.zohoAccountName"
                expression="$func:zohoAccountName"/>
	 
     
      <activecollab.init>
         <apiUrl>{$ctx:uri.var.activecollabApiUrl}</apiUrl>
         <apiToken>{$ctx:uri.var.activecollabApiToken}</apiToken>
         <format>json</format>
      </activecollab.init>
      <activecollab.listCompanies/>
	 
		<script language="js">
			var companies = mc.getPayloadJSON();
			var zohoAccountName = mc.getProperty("uri.var.zohoAccountName");
			
			for(var i = 0; i &lt; companies.length ; i++ ){
				var company=companies[i];
				
				
				if(company.name == zohoAccountName){
					mc.setProperty('uri.var.activecollabCompanyId',""+company.id);
					
					
				}
				
			}
		</script>
	</sequence>
</template>
Sample proxy for creating ActiveCollab projects
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="activeCollab_retrievePotentialsAndInitiateProject"
       transports="https http"
       startOnLoad="true"
       trace="disable">
   <description/>
   <target>
      <inSequence onError="faultHandlerSeq">
         <property name="zohoApiUrl" expression="json-eval($.zohoApiUrl)"/>
         <property name="zohoAccessToken" expression="json-eval($.zohoAccessToken)"/>
         <property name="zohoScope" expression="json-eval($.zohoScope)"/>
         <property name="zohoNewFormat" expression="json-eval($.zohoNewFormat)"/>
         <property name="zohoVersion" expression="json-eval($.zohoVersion)"/>
         <property name="zohoStatus" expression="json-eval($.zohoStatus)"/>
         <property name="activecollabApiUrl" expression="json-eval($.activecollabApiUrl)"/>
         <property name="activecollabApiToken"
                   expression="json-eval($.activecollabApiToken)"/>
		<property name="index" value="0" scope="operation"/>
		<property name="responseString" value="" scope="operation"/>
		
		<!-- Retrieve all Potentials from ZohoCRM -->
		<script language="js">
		 var currentDate=new Date();
		 var previousDate = new Date(currentDate.getFullYear(),currentDate.getMonth(),currentDate.getDate()-1);
		 var dateString=previousDate.getFullYear() + "-" + Number(previousDate.getMonth()+1) + "-" + previousDate.getDate() +" 00:00:00";
		 mc.setProperty('lastModifiedTime', dateString);
		 
		 </script>
		 
         <zohocrm.init>
            <scope>{$ctx:zohoScope}</scope>
            <accessToken>{$ctx:zohoAccessToken}</accessToken>
            <apiUrl>{$ctx:zohoApiUrl}</apiUrl>
         </zohocrm.init>
         <zohocrm.getRecords>
            <newFormat>{$ctx:zohoNewFormat}</newFormat>
            <version>{$ctx:zohoVersion}</version>
            <moduleType>Potentials</moduleType>
			<lastModifiedTime>{$ctx:lastModifiedTime}</lastModifiedTime>
         </zohocrm.getRecords>
		
		 <property name="messageType" value="application/xml" scope="axis2"/>
		 
		 <property name="potentialsCount"
                   expression="count(//response/result/Potentials/row)"
                   scope="operation"/>
		<!-- Checking if there are any potentials to be processed, else skipping. -->	
		<filter xpath="0 != get-property('operation', 'potentialsCount')">
				<then>
					<iterate continueParent="true"
						  id="potentialsIterator"
						  preservePayload="true"
						  expression="//response/result/Potentials/row"
						  sequential="true">
					<target>
					   <sequence>
							
							<property name="zohoPotentialId" expression="//FL[1]/content/text()"/>
						 <!-- Calling activecollab-retrievePotentialsAndInitiateProject template to create projects in ActiveCollab-->    
							<call-template target="activecollab-retrievePotentialsAndInitiateProject">
								<with-param name="zohoApiUrl" value="{$ctx:zohoApiUrl}"/>
								<with-param name="zohoAccessToken" value="{$ctx:zohoAccessToken}"/>
								<with-param name="zohoScope" value="{$ctx:zohoScope}"/>
								<with-param name="zohoPotentialId" value="{$ctx:zohoPotentialId}"/>
								<with-param name="zohoNewFormat" value="{$ctx:zohoNewFormat}"/>
								<with-param name="zohoVersion" value="{$ctx:zohoVersion}"/>
								<with-param name="zohoStatus" value="{$ctx:zohoStatus}"/>
								<with-param name="activecollabApiToken" value="{$ctx:activecollabApiToken}"/>
								<with-param name="activecollabApiUrl" value="{$ctx:activecollabApiUrl}"/>
								
							</call-template> 
							<property name="index" expression="get-property('operation','index') + 1" scope="operation"/>
						</sequence>
					</target>
				 </iterate>	
				<filter xpath="get-property('operation','index') = get-property('operation', 'potentialsCount')" >
					<then>
						<loopback />
					</then>
				</filter>		
			</then>
			<else>
				<property name="idParam" value=" " />
				<property name="status" value="Skipped" />
				<property name="message" value="No potentials were found." />
					
				<call-template target="responseHandlerTemplate">
					<with-param name="id" value="{$ctx:idParam}" />
					<with-param name="status" value="{$ctx:status}" />
					<with-param name="message" value="{$ctx:message}" />
				</call-template>
					
				<loopback />
			</else>
		</filter>	
			
		</inSequence>
		<outSequence>
        <property name="messageType" value="application/json" scope="axis2"/>
         
        
		<payloadFactory media-type="json">
            <format>
				{
				"Response":{
					"activity":"activecollab-createProjectFromZohoPotentials",
					"activityResponse":[$1]
				}
				}
			</format>
            <args>
				
                <arg evaluator="xml" expression="get-property('operation', 'responseString')"/>
            </args>
        </payloadFactory>
		
        <send/>
      </outSequence>
   </target>
</proxy>                                                           
Sample request for creating ActiveCollab projects
{
	"zohoApiUrl":"https://crm.zoho.com",
	"zohoAccessToken":"e6cbeb86661abf9922a0d95ccc9b124b",
	"zohoScope":"crmapi",
	"zohoNewFormat":"1",
	"zohoVersion":"1",
	"activecollabApiUrl":"https://virtusajpc.manageprojects.com",
	"activecollabApiToken":"1-JwWMlV9kjmeNJ1j4OPlm4CDUqdZ09QxHcjin6fye"
}
  • No labels