Salesforce, Talend (tMap), Data Loading...Avoid VLookup

Saturday, February 26, 2011 by Aslam - The Alexendra
Hi All,
Today I will give you some demonstration about data loading with Talend. I am taking one special case in which generally people use VLookup function from excel to match the lookup ids and fill the records csv column and then upload. For example, you have one CSV file for Contacts which you want to insert into salesforce, that CSV contains 'Account Name'. But you need AccountId to successfully insert contact records. For solving this people generally do this approach.

1) Fetch all account names and ids from salesforce and make one csv
2) Use the VLookup function to match Account Name from csv2 to CSV1 and set the extra column in CSV1 for AccountId (generally people struggle here :) )
3) Then use final CSV1 to upload the data

So, I am here to tell you easy upload approach using Talend tMAP to avoid any VLookup headache and simply upload data successfully.




Follow this approach.
1) Create a new Job
2) Select File->tFileInputDelimited and set your CSV input file here
3) Select Business->Salesforce->tSalesforceOutputBulkExec, set your salesforce credentials where you want to upload the data
4) Select Business->Salesforce->tSalesforceInput, set your salesforce credentials from where you want to fetch the Account Ids and Account Names data, Set your query here
5) Select Processing->tMap, this is the heart of whole process
6) Double click on tMap, set the mapping here, CSV1->AccountName TO tSalesforceInput->Name. Drag relavent columns to your salesforce output file, Set the ID from tSalesforceInput to tSalesforceOutputBulkExec->AccountId
7) Now save your complete Job
8) Run the job and it will give you output as results.

Here is the Screencast to see complete process as vedio.
http://screencast.com/t/J8tUcer963u4

Here are more links which can help you to run and use Talend
http://techblog.appirio.com/2009/08/using-talend-to-export-data-from.html
http://techblog.appirio.com/search/label/Talend
http://techblog.appirio.com/2011/01/loading-data-to-salesforcecom-with-bulk.html
http://techblog.appirio.com/2009/12/performing-lookups-and-transformations.html

Hopefully this will help some people to try Talend and finding its benifits.

Thanks
Aslam Bari

Barcode, Salesforce and PDF

Wednesday, February 16, 2011 by Aslam - The Alexendra
Hi All,
Recently I faced one issue where i need to generate Barcode on the fly in VF and also render that as PDF. I searched on Net and community, found some people have done Barcode generation using Javascript. But in my case i need to render it as PDF and VF does not support Javascript when renderAs PDF. So i decided to go the way to generate Barcode image. The first thing came in my mind is PHP/GD way to generate Barcode image and use that url in VF to show image. Then i found this site useful and very useful PHP script which fits my need
http://www.sid6581.net/cs/php-scripts/barcode/

I used this script, done some modification in this and hosted on my site And used in my VF page as below:-

<apex:image value="http://www.aslambari.com/barcode.php?barcode=CS1001&width=200&text=1&height=100" />


Here is some details about how you use the url and parameters to generate barcode:
URL: http://www.aslambari.com/barcode.php
Params:
barcode: [any text to render as barcode]
text: [0 or 1]
format: [jpeg/png/gif]
width: [the width you want]
height: [the height you want]



It works great if my VF render as normal HTML page, but as soon as i make it renderAs="PDF", VF again not works, it does not allow dynamic generated images. So again i got disappointed.
Then i thought again and did apex code to fetch the dynamic binary data generated my PHP site url and save it into attachment and use that url in my VF page. I was thinking this time i will win for sure, but again it did not work. HttpResponse does not allow Blob response, it always gives response as String and that mingled my image data. Disappointed again.

Then finally i have decided to create dynamic generated barcode on PHP and save as temprary images and use that url in my img tag and renderAs="PDF", this time i got success :)

Here is the working demo for my work:-
https://labsprojects-developer-edition.ap1.force.com/BarCodeSample

If you need complete code for above demo site, here is the link:
http://www.aslambari.com/SF_Barcode.zip

Enjoy barcoding :)

Thanks
Aslam Bari

ApexDoc Eclipse Plugin For Force.com IDE

Tuesday, February 1, 2011 by Aslam - The Alexendra
Hi All,
I am very happy to announce that now ApexDoc is available as Native "Eclipse Plugin". So no more need to go command line and provide parameters. You can simply go to your Force.IDE, select your classes folder, right click on that and Generate your ApexDoc, all in one place. Isn't it cool :)


Ok, so here is the guidelines, how to install the plugin and use it.

1) Go to http://www.aslambari.com/apexdocplugin.html

2) Download the plugin from there. It will give you one plugins.zip file. Unzip that file.

3) You will get one "com.apex.doc_1.0.0.jar" file. Copy this file.

4) Go to your eclipse installation directory and find your plugins folder there, For example D:\Eclipse\plugins

5) Paster the copied jar file into this directory.

6) Now restart (if eclispe is already running) your eclipse

7) Now go to any Force.com Project you have setup in your eclipse. Open the classes folder.

8) Right click on that folder, from shortcut menu select "Force.com", a sub menu will appear, you can see "Generate ApexDoc..." menu item in your submenu.



9) Now click on "Generate ApexDoc...". One ApexDoc dialog box will open.



10) All options here are self explanatory. The "Source Directory" is already filled up your selection. The "Target Directory" is where you want to generate output Documentation generated. "Home HTML File" is your sample home file for index page. "Author File" is for header areas for documentation.

11) Select appropriate options and Click on "Generate" button. It will generate documentation on your selected target directory and you will be prompted one message dialog that says "DONE"

12) If there is any issue, not generated your documentation, you can find one log file generated in your eclipse installation with name "apex_doc_log.txt".

So, this is very useful for Force.com developers and non programmers to use this plugin tool. You can also check one screenshot here: http://www.aslambari.com/apexdocplugin.html

For learning how comments syntax will be in your code refer my previous blog:
http://techsahre.blogspot.com/2011/01/apexdoc-salesforce-code-documentation.html

The plugin is in pre-mature stage and may contains bugs. Feel free to report me all bugs or enhancement you find, on my email. I will try to fix those.

So enjoy documenting :)

Thanks
Aslam Bari