Sunday, November 26, 2017

Generating Java Class files from salesforce wsdl using Apache Axis and sforce.ws.tools and command prompt - salesforce/ webserevice login url


Hi,

I am mentioning the source code to generate the .class files from wsdl using Apache Axis jar files.
I am using the salesforce wsdl file. Creating the class files procedure will not change for other wsdl files when using apache axis.

There are two ways to generate the .class files one is using apache axis and other is using the sforce.ws.tools.


I . Generate java .class files using apache axis.

  • Jar files required 
    • axis.jar;
    • axis-ant.jar;
    • commons-discovery-0.2.jar;
    • commons-logging-1.0.4.jar;
    • dsn.jar;
    • imap.jar;
    • jaxrpc.jar;
    • log4j-1.2.8.jar;
    • mailapi.jar;
    • pop3.jar;
    • saaj.jar;
    • smtp.jar;
    • wsdl4j-1.5.1.jar
You can use the latest mentioned .jar files as per the latest versions available.

2. Save all the jar files in the folder location where you want to generate the .class files and set the classpath of the jar files in the environment variables.

3. Save the wsdl file from salesforce API ( you can select partner/enterprise based on requirement).

4.  open the cmd prompt and change the directory where the .jar files are located.

5. execute the below command

 java -classpath axis.jar;axis-ant.jar;commons-discovery-0.2.jar;commons-logging-1.0.4.jar;dsn.jar;imap.jar;jaxrpc.jar;log4j-1.2.8.jar;mailapi.jar;pop3.jar;saaj.jar;smtp.jar;wsdl4j-1.5.1.jar org.apache.axis.wsdl.WSDL2Java -a enterprise.wsdl.

Please comment if you are getting any error messages in the procedure.

I have compiled this using java 1.8 version.

Sunday, July 30, 2017

How to get RecordType name of an object Salesforce


How to get RecordTypeName of an object in Salesforce.




Step 1:
Declare this like initialization parameter before any loop

Map<ID, Schema.RecordTypeInfo> recordTypeMap = Schema.SObjectType.Case.getRecordTypeInfosById();


Change the object accordingly.


Step 2 : 

Get the  Record type as String like below.

String recordtypeName =  recordTypeMap.get(case.RecordTypeId).getName(); 


Full Example :

class { 

List<Case> caseList = [Select id, name,status from case limit 100];

    List<Case> toUpdate = new List<Case>();

Map<ID, Schema.RecordTypeInfo> recordTypeMap = Schema.SObjectType.Case.getRecordTypeInfosById();
   
    for (Case c : caseList){
        if(
recordTypeMap.get(c.RecordTypeId).getName()  ==  '*******'){
            case cxUpdate = new Case();
            cxUpdate.id = c.id;
            cxUpdate.status = 'In Support';
            toUpdate.add(cxUpdate);
        }
        update toUpdate;   
    }

 

}
 



 

Look up fields in Salesforce Flow Datatable

How to fetch lookup fields on flow datatable in Salesforce Flows. Think before you get the solution, this is what one of my colleague(Hans) ...