Hi All,

I am working on to create a sample scenario with ESB connectors Salesforce
SOAP, Google Spreadsheet and Gmail. For that, I used create method of Sf
SOAP connector to create the Lead and from the response of that method we
can able to get the Id of that record and using that Id we can able to
retrieve the information about that Lead creation using retrieve method.
After that, we need to insert the needed information of that record to a
spreadsheet using Google Spreadsheet connector using addRowsData method and
from getCellData method, we can able to retrieve the information about the
record. And finally, we can build the message body with the above
information and send an alert to the manager about the Lead creation using
Gmail Connector.

Please find the above use case explanation in [1] and sample proxy can be
found in the attached file.

[1] -
[image: Inline image 1]

-- 


*Thank you and Regards,**Hariprasath Thanarajah*
Software Engineer | WSO2
E: [email protected]
M: +94 75 2806528, +94 77 7216903
Blog: hariwso2.blogspot.com

Skype : hariss636
LinkedIn : https://www.linkedin.com/in/hariprasath-thanarajah-5234b660

WSO2, Inc.
lean . enterprise . middleware

https://wso2.com/signature
http://wso2.com/about/team/hariprashath-thanarajah/
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse";
       name="create"
       startOnLoad="true"
       statistics="disable"
       trace="disable"
       transports="https,http">
   <target>
      <inSequence>
         <payloadFactory media-type="xml">
            <format>
               <sfdc:sObjects xmlns:sfdc="sfdc" type="Lead">
                  <sfdc:sObject>
                     <sfdc:FirstName>abc123</sfdc:FirstName>
                     <sfdc:LastName>safda</sfdc:LastName>
                     <sfdc:Email>[email protected]</sfdc:Email>
                     <sfdc:Company>WSO2</sfdc:Company>
                  </sfdc:sObject>
               </sfdc:sObjects>
            </format>
            <args/>
         </payloadFactory>
         <salesforce.create configKey="sfConfig">
            <allOrNone>0</allOrNone>
            <allowFieldTruncate>0</allowFieldTruncate>
            <sobjects xmlns:sfdc="sfdc">{//sfdc:sObjects}</sobjects>
         </salesforce.create>
         <payloadFactory media-type="xml">
            <format>
               <sfdc:sObject xmlns:sfdc="sfdc">
                  <sfdc:Ids>$1</sfdc:Ids>
               </sfdc:sObject>
            </format>
            <args>
               <arg xmlns:ns="urn:partner.soap.sforce.com"
                    evaluator="xml"
                    expression="//ns:createResponse/ns:result/ns:id/text()"/>
            </args>
         </payloadFactory>
         <salesforce.retrieve configKey="sfConfig">
            <fieldList>FirstName,LastName,Email</fieldList>
            <objectType>Lead</objectType>
            <objectIDS xmlns:sfdc="sfdc">{//sfdc:sObject}</objectIDS>
         </salesforce.retrieve>
         <property xmlns:urn="urn:sobject.partner.soap.sforce.com"
                   xmlns:ns="urn:partner.soap.sforce.com"
                   expression="//ns:retrieveResponse/ns:result/urn:Email/text()"
                   name="salesforce.lead.email"
                   scope="default"
                   type="STRING"/>
         <property xmlns:urn="urn:sobject.partner.soap.sforce.com"
                   xmlns:ns="urn:partner.soap.sforce.com"
                   expression="//ns:retrieveResponse/ns:result/urn:Id/text()"
                   name="salesforce.lead.id"
                   scope="default"
                   type="STRING"/>
         <property xmlns:urn="urn:sobject.partner.soap.sforce.com"
                   xmlns:ns="urn:partner.soap.sforce.com"
                   expression="//ns:retrieveResponse/ns:result/urn:FirstName/text()"
                   name="salesforce.lead.firstname"
                   scope="default"
                   type="STRING"/>
         <property xmlns:urn="urn:sobject.partner.soap.sforce.com"
                   xmlns:ns="urn:partner.soap.sforce.com"
                   expression="//ns:retrieveResponse/ns:result/urn:LastName/text()"
                   name="salesforce.lead.lastname"
                   scope="default"
                   type="STRING"/>
         <script language="js">var mail = mc.getProperty("salesforce.lead.email");
			    var id = mc.getProperty("salesforce.lead.id");
			    var fname = mc.getProperty("salesforce.lead.firstname");
			    var lname = mc.getProperty("salesforce.lead.lastname");                           
                          
                            print("Time Duration :  " + id + " ms ");
                            var fields = "[[";                         
                            
                            if(mail !="" &amp;&amp; mail !=null &amp;&amp; id !="" &amp;&amp; id !=null &amp;&amp; fname !="" &amp;&amp; fname !=null &amp;&amp; lname !="" &amp;&amp; lname !=null){
                                    fields = fields.concat('"' + mail + '","' + id + '","' + fname + '","' + lname + '"');
                            }
                            fields = fields.concat("]]");
                            mc.setProperty("spreadsheet.lead.raw",fields);</script>
         <googlespreadsheet.addRowsColumnsData configKey="sheetConfig">
            <spreadsheetId>1P-gBRsCqj1gdqz9-cvlRn5I0gGsMQALLu07Qtgm7ggg</spreadsheetId>
            <range>Sheet1!A1</range>
            <valueInputOption>RAW</valueInputOption>
            <values>{$ctx:spreadsheet.lead.raw}</values>
         </googlespreadsheet.addRowsColumnsData>
         <property expression="json-eval($.updates.updatedRange)"
                   name="spreadsheet.lead.updatedRange"/>
         <googlespreadsheet.getCellData configKey="sheetConfig">
            <spreadsheetId>1P-gBRsCqj1gdqz9-cvlRn5I0gGsMQALLu07Qtgm7ggg</spreadsheetId>
            <range>{$ctx:spreadsheet.lead.updatedRange}</range>
         </googlespreadsheet.getCellData>
         <property expression="json-eval($.values[0][0])" name="spreadsheet.lead.mailId"/>
         <property expression="json-eval($.values[0][1])" name="spreadsheet.lead.sfId"/>
         <property expression="json-eval($.values[0][2])"
                   name="spreadsheet.lead.firstName"/>
         <property expression="json-eval($.values[0][3])" name="spreadsheet.lead.lastName"/>
         <script language="js">
			    var mail = mc.getProperty("spreadsheet.lead.mailId");
			    var id = mc.getProperty("spreadsheet.lead.sfId");
			    var fname = mc.getProperty("spreadsheet.lead.firstName");
			    var lname = mc.getProperty("spreadsheet.lead.lastName");                           
                          
                            print("Time Duration :  " + id + " ms ");
                            var contentType = "The New Lead Registration detail is: \n"                         
                            
                            if(mail !="" &amp;&amp; mail !=null &amp;&amp; id !="" &amp;&amp; id !=null &amp;&amp; fname !="" &amp;&amp; fname !=null &amp;&amp; lname !="" &amp;&amp; lname !=null){
                                    contentType = contentType.concat('"The Email Id is: ' + mail + '\n","The Salesforce Id is: ' + id + '\n","The Firstname is: ' + fname + '\n","The Lastname is: ' + lname + '"');
                            }
                            
                            mc.setProperty("gmail.lead.contentBody",contentType);</script>
         <gmail.init>
            <userId>[email protected]</userId>
            <refreshToken>1/AXXuBSzhR90-w1daRxxxxxxxxxxxxxxxxxxxH06Qo</refreshToken>
            <clientSecret>qlCLwJN9mBxSxxxxxxxxxxxs9i2</clientSecret>
            <clientId>592473284170-upbhlaj85xxxxxxxxxxxxxxxgoogleusercontent.com</clientId>
            <accessToken>ya29.GluUBFt9AAMvnctxxxxxxxxxxxxxxxxxxxAYWmBlA0G8jr8WUz6PI9O51gGCHSXzxZFsEKPeAxCwWQagcOUlwJBJrpqk7kgVrfrmx_sM34PsySi</accessToken>
            <apiUrl>https://www.googleapis.com/gmail</apiUrl>
         </gmail.init>
         <gmail.sendMail>
            <to>[email protected]</to>
            <subject>New Lead Registration</subject>
            <from>[email protected]</from>
	    <contentType>text/html; charset=UTF-8</contentType>
            <messageBody>{$ctx:gmail.lead.contentBody}</messageBody>
         </gmail.sendMail>
         <send/>
      </inSequence>
   </target>
   <description/>
</proxy>
                                
_______________________________________________
Architecture mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture

Reply via email to