Tuesday, December 22, 2015

Get record count from salesforce group by createddate

SELECT Count(Id), calendar_year(CreatedDate) from Task
GROUP BY calendar_year(CreatedDate)
Order By calendar_year(CreatedDate)

Tuesday, May 13, 2014

Power Partner User:

To bulk load Partner user in salesforce below are the steps:

1. Create those Partner Users as Contact.
2. But to create contact we should create account first.
3. Create account and enable this account as partner account.
4. Load all contact under the account created in step 3 with ispartner=TRUE
5. Now create 1 user with correct account and contact id populated
6. step 5 will create partner role now update users role with appropriate role ids
7. create bulk users same way we created in step 5

Tuesday, April 29, 2014

Get Object Name of activity whatid

week before I came across the situation where task whoid and whatid are associated with many custom object and prob was how to find the object name. Object Name is required since when migrating task records then these object ids will change.

so below is the option i tried to get the Object name with objectPrefix values

String objPrefix  =  '800';              //replace this with your object first 3 digit

Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();
for(Schema.SObjectType objectInstance : gd.values())
{
if(objectInstance.getDescribe().getKeyPrefix() == objPrefix )
{
System.debug('Object Name is: '+ objectInstance.getDescribe().getName());
}
}

Thursday, March 27, 2014

Today, when i tried to export attachment related to account. i could not export because salesforce doesn't provide way of using string function on lookup object.

so what i did :

integer i=0;
for(Attachment a :[SELECT id,parentid  FROM Attachment]){
 string s =a.parentid ;
  if(s.startsWith('001')){
     i = i+1;
   }
}

system.debug('NUMBER OF ATTACHMENT==============='+i);

Thursday, February 13, 2014

Using Date format to fetch data from SQL in talend

this is how context variable can be used

"SELECT * FROM ACCOUNTS WHERE
TO_DATE(CREATEDATE, 'YYYY-MM-DD\"T\"HH24:MI:SS') <= " + context.LastRunTime + " AND
TO_DATE(LASTMODIFIEDDATE, 'YYYY-MM-DD\"T\"HH24:MI:SS') > " + context.LastRunTime

Thursday, November 21, 2013

What if excel can't remove trailing space using TRIM function


Today i wondered when excel clean and trim function could not do what it supposed to. Reason was content was copied from net and have trailing spaces. These trailing spaces are due to &nbsp which is hidden.

so I used below function within excel to get the removed trailing spaces
=TRIM(SUBSTITUTE(B1,CHAR(160),CHAR(32)))

First substitute  ASCII character for &nbsp i.e. 160 with the ASCII code for normal space i.e. 32
and in last TRIM will do it's job.

Tuesday, August 27, 2013

Salesforce Bulk API behavior with Talend



When using Talend to move records from Oracle DB to SFDC i got an error like this.

Exception in component tSalesforceOutputBulkExec_1_tSBE
[AsyncApiException  exceptionCode='InvalidBatch'
exceptionMessage='Records not processed'
]

after researching and trying lot options I found Talend taken default schema when I refreshed schema and it worked fine.