Gouranga Sadhukhan's Blog
Wednesday, February 6, 2019
Wednesday, July 13, 2016
What is the difference between Standard Controller and Custom Controller extension ?
A custom
controller is an
Apex class that implements all of the logic for a page without leveraging a
standard controller. Use custom controllers when you want your Visualforce page
to run entirely in system mode, which does not enforce the permissions and
field-level security of the current user.
A controller
extension is an Apex
class that extends the functionality of a standard or custom controller. Use
controller extensions when:
·
You want to leverage the built-in functionality of a standard
controller but override one or more actions, such as edit, view, save, or
delete.
·
You want to add new actions.
·
You want to build a Visualforce page that respects user
permissions. Although a controller extension class executes in system mode, if
a controller extension extends a standard controller, the logic from the
standard controller does not execute in system mode. Instead, it executes in
user mode, in which permissions, field-level security, and sharing rules of the
current user apply.
Thursday, September 10, 2015
127.0.0.1' is not recognized as an internal or external command operable program or batch file
In 7.0.56 in bin/catalina.bat:179 and 184
:noJuliConfig
set "JAVA_OPTS=%JAVA_OPTS% %LOGGING_CONFIG%"
..
:noJuliManager
set "JAVA_OPTS=%JAVA_OPTS% %LOGGING_MANAGER%"
to
:noJuliConfig
set JAVA_OPTS=%JAVA_OPTS% %LOGGING_CONFIG%
..
:noJuliManager
set JAVA_OPTS=%JAVA_OPTS% %LOGGING_MANAGER%
Thursday, August 20, 2015
The request was aborted: Could not create SSL/TLS secure channel.
C# Code
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateServerCertificate);
public static bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors policyErrors)
{
return true;
}
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateServerCertificate);
public static bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors policyErrors)
{
return true;
}
Wednesday, August 19, 2015
Salesforce APEX: Class variable/property are access dynamically
1. Class description
public class mobile
{
public string SMS{get;set;}
public string calling{get;set;}
}
{
public string SMS{get;set;}
public string calling{get;set;}
}
2. your code to pick property value dynamically
mobile m =new mobile();
m.SMS='SMS Test';
m.calling='My Calling';
m.SMS='SMS Test';
m.calling='My Calling';
String serialized = JSON.serialize(m); // object convert JSON string
Map<String, Object> parameters = new Map<String, Object>();
parameters = (Map<String, Object>) JSON.deserializeUntyped(serialized);
string fieldvalue=parameters.get( 'SMS');
string
fieldvalue2=parameters.get(‘calling’);
Monday, July 13, 2015
SWIFT Parser like MT103, MT101, MT940 etc
SWIFT Messages Parser
Any SWIFT messages can parse with header or without header. These message format MT103, MT101, MT940 etc. files can be parse using below code. and multi massages or single massages
Code link
Code link
Multi massages Parser
List<SwiftParser.SwiftParser> files=obj.SWIFTParser(content);
"BasicHeaderBlock : " + files[0].BasicHeaderBlock
"ApplicationHeaderBlock : " + files[0].ApplicationHeaderBlock
"TrailerBlock : " + files[0].TrailerBlock
"Messages Count : " + files.Count.ToString()
datagrid.DataSource = files[0].FileMessages.FileContent
Massage Body Parser
SwiftParser.SwiftParser file = new SwiftParser.SwiftParser();
obj.ParserBody(file, s);
files.Add(file);
Multi Massages Body Parser
string[] SeparatorsField = new string[] { Environment.NewLine + "-" };
string[] findata = content.Split(SeparatorsField, StringSplitOptions.None);
List<SwiftParser.SwiftParser> files = new List<SwiftParser.SwiftParser>();
foreach(string s in findata)
{
SwiftParser.SwiftParser file = new SwiftParser.SwiftParser();
obj.ParserBody(file, s);
files.Add(file);
}
Friday, July 3, 2015
Salesforce Bulk API using C#
The Bulk API provides programmatic
access to allow you to quickly load your organization's data into Salesforce
C# Code use following link
The steps are
Logging salesforce to generate
session Id using Soap api or rest api
public bool login()
{
try
{
binding = new SforceService();
LoginResult lr = binding.login(UserName,
Password);
binding.Timeout = 60000;
binding.Url = lr.serverUrl;
binding.SessionHeaderValue = new SessionHeader();
binding.SessionHeaderValue.sessionId = lr.sessionId;
sessionId = lr.sessionId;
string ServerUrl = "https://emea.salesforce.com/services/async/34.0/job";
int tempurl = lr.serverUrl.IndexOf(".salesforce.com");
string ServerInstance =
lr.serverUrl.Substring(8, tempurl - 8);
ServerUrl = ServerUrl.Replace("emea", ServerInstance);
CurentServerUrl = ServerUrl;
WriteLog(CurentServerUrl);
WriteLog("Login
Successfully completed and Session Id: " + sessionId);
return true;
}
catch (Exception ex)
{
WriteLog(ex.Message);
return false;
}
}
Create Job using Job XML
Set Header :: X-SFDC-Session : sessionId
Set Content Type: contentType: application/xml;
charset=UTF-8
Xml Data:
<?xml version="1.0"
encoding="UTF-8"?>
<jobInfo
xmlns="http://www.force.com/2009/06/asyncapi/dataload">
<operation>upsert</operation>
<object>Object1__c</object>
<externalIdFieldName>Email__c</externalIdFieldName>
<contentType>CSV</contentType>
</jobInfo>
Response : <?xml
version="1.0" encoding="UTF-8"?><jobInfo
xmlns="http://www.force.com/2009/06/asyncapi/dataload">
<id>75090000002tCVOAA2</id>
<operation>upsert</operation>
<object>Object1__c</object>
<createdById>00590000003i6nuAAA</createdById>
<createdDate>2015-07-03T12:22:25.000Z</createdDate>
<systemModstamp>2015-07-03T12:22:25.000Z</systemModstamp>
<state>Open</state>
<externalIdFieldName>Email__c</externalIdFieldName>
<concurrencyMode>Parallel</concurrencyMode>
<contentType>CSV</contentType>
<numberBatchesQueued>0</numberBatchesQueued>
<numberBatchesInProgress>0</numberBatchesInProgress>
<numberBatchesCompleted>0</numberBatchesCompleted>
<numberBatchesFailed>0</numberBatchesFailed>
<numberBatchesTotal>0</numberBatchesTotal>
<numberRecordsProcessed>0</numberRecordsProcessed>
<numberRetries>0</numberRetries>
<apiVersion>34.0</apiVersion>
<numberRecordsFailed>0</numberRecordsFailed>
<totalProcessingTime>0</totalProcessingTime>
<apiActiveProcessingTime>0</apiActiveProcessingTime>
<apexProcessingTime>0</apexProcessingTime>
</jobInfo>
Submit Data in to Job/ Create Batch in Job
string ServerURL = "";
string Request = "";
string response = "";
string ct = "";
XmlDocument objXMLDoc = new XmlDocument();
ServerURL = CurentServerUrl+"/" + JobId + "/batch";
WriteLog(ServerURL);
Request = Data;
Dictionary<string, string> headder = new Dictionary<string, string>();
headder.Add("X-SFDC-Session", sessionId);
if (CurrentContentType == ContentType.CSV)
{
ct = "text/csv";
}
else
{
ct = "text/xml";
}
WriteLog(Request);
response = HttpClient.dopost(ServerURL, Request, headder, "POST", ct);
WriteLog(response);
objXMLDoc = new XmlDocument();
objXMLDoc.LoadXml(response);
//response = objXMLDoc.InnerText;
string batchId = objXMLDoc.ChildNodes[1].FirstChild.InnerText;
currentBatchId = batchId;
WriteLog("Batch Id :" + currentBatchId);
return response;
Url : https://ap1.salesforce.com/services/async/34.0/job/75090000002tCVOAA2/batch
Request :
Account__r.Account_External_Id__c,Checked__c,Datatime__c,Date__c,Email__c,Name,Number__c
3,TRUE,2015-07-03T06:55:00.000Z,2015-07-02,gs1@accesspay.com,Object1,1253
3,FALSE,2015-07-03T06:55:00.000Z,2015-07-03,gs2@accesspay.com,Object2,1254
3,TRUE,2015-07-03T06:55:00.000Z,2015-07-04,gs3@accesspay.com,Object3,1255
1,FALSE,2015-07-03T06:55:00.000Z,2015-07-05,gs4@accesspay.com,Object4,1256
Response :
<?xml version="1.0" encoding="UTF-8"?><batchInfo
xmlns="http://www.force.com/2009/06/asyncapi/dataload">
<id>75190000004FslWAAS</id>
<jobId>75090000002tCVOAA2</jobId>
<state>Queued</state>
<createdDate>2015-07-03T12:22:59.000Z</createdDate>
<systemModstamp>2015-07-03T12:22:59.000Z</systemModstamp>
<numberRecordsProcessed>0</numberRecordsProcessed>
<numberRecordsFailed>0</numberRecordsFailed>
<totalProcessingTime>0</totalProcessingTime>
<apiActiveProcessingTime>0</apiActiveProcessingTime>
<apexProcessingTime>0</apexProcessingTime>
</batchInfo>
Submit Data in to Job/ Create Batch in Job
string ServerURL = "";
string Request = "";
string response = "";
string ct = "";
XmlDocument objXMLDoc = new XmlDocument();
ServerURL = CurentServerUrl+"/" + JobId + "/batch";
WriteLog(ServerURL);
Request = Data;
Dictionary<string, string> headder = new Dictionary<string, string>();
headder.Add("X-SFDC-Session", sessionId);
if (CurrentContentType == ContentType.CSV)
{
ct = "text/csv";
}
else
{
ct = "text/xml";
}
WriteLog(Request);
response = HttpClient.dopost(ServerURL, Request, headder, "POST", ct);
WriteLog(response);
objXMLDoc = new XmlDocument();
objXMLDoc.LoadXml(response);
//response = objXMLDoc.InnerText;
string batchId = objXMLDoc.ChildNodes[1].FirstChild.InnerText;
currentBatchId = batchId;
WriteLog("Batch Id :" + currentBatchId);
return response;
Url : https://ap1.salesforce.com/services/async/34.0/job/75090000002tCVOAA2/batch
Account__r.Account_External_Id__c,Checked__c,Datatime__c,Date__c,Email__c,Name,Number__c
3,TRUE,2015-07-03T06:55:00.000Z,2015-07-02,gs1@accesspay.com,Object1,1253
3,FALSE,2015-07-03T06:55:00.000Z,2015-07-03,gs2@accesspay.com,Object2,1254
3,TRUE,2015-07-03T06:55:00.000Z,2015-07-04,gs3@accesspay.com,Object3,1255
1,FALSE,2015-07-03T06:55:00.000Z,2015-07-05,gs4@accesspay.com,Object4,1256
Response :
<?xml version="1.0" encoding="UTF-8"?><batchInfo
xmlns="http://www.force.com/2009/06/asyncapi/dataload">
<id>75190000004FslWAAS</id>
<jobId>75090000002tCVOAA2</jobId>
<state>Queued</state>
<createdDate>2015-07-03T12:22:59.000Z</createdDate>
<systemModstamp>2015-07-03T12:22:59.000Z</systemModstamp>
<numberRecordsProcessed>0</numberRecordsProcessed>
<numberRecordsFailed>0</numberRecordsFailed>
<totalProcessingTime>0</totalProcessingTime>
<apiActiveProcessingTime>0</apiActiveProcessingTime>
<apexProcessingTime>0</apexProcessingTime>
</batchInfo>
Close Job
string ServerURL = "";
string Request = "";
string response = "";
ServerURL = CurentServerUrl+"/" + JobId;
WriteLog(ServerURL);
Request = bulk.CloseJob;
Dictionary<string, string> headder = new Dictionary<string, string>();
headder.Add("X-SFDC-Session", sessionId);
WriteLog(Request);
response = HttpClient.dopost(ServerURL, Request,
headder, "POST", "application/xml; charset=UTF-8");
WriteLog(response);
return response;
URL : https://ap1.salesforce.com/services/async/34.0/job/75090000002tCVOAA2
Request:
<?xml version="1.0" encoding="UTF-8"?>
<jobInfo xmlns="http://www.force.com/2009/06/asyncapi/dataload">
<state>Closed</state>
</jobInfo>
Response :
<?xml version="1.0" encoding="UTF-8"?><jobInfo
xmlns="http://www.force.com/2009/06/asyncapi/dataload">
<id>75090000002tCVOAA2</id>
<operation>upsert</operation>
<object>Object1__c</object>
<createdById>00590000003i6nuAAA</createdById>
<createdDate>2015-07-03T12:22:25.000Z</createdDate>
<systemModstamp>2015-07-03T12:22:25.000Z</systemModstamp>
<state>Closed</state>
<externalIdFieldName>Email__c</externalIdFieldName>
<concurrencyMode>Parallel</concurrencyMode>
<contentType>CSV</contentType>
<numberBatchesQueued>1</numberBatchesQueued>
<numberBatchesInProgress>0</numberBatchesInProgress>
<numberBatchesCompleted>0</numberBatchesCompleted>
<numberBatchesFailed>0</numberBatchesFailed>
<numberBatchesTotal>1</numberBatchesTotal>
<numberRecordsProcessed>0</numberRecordsProcessed>
<numberRetries>0</numberRetries>
<apiVersion>34.0</apiVersion>
<numberRecordsFailed>0</numberRecordsFailed>
<totalProcessingTime>0</totalProcessingTime>
<apiActiveProcessingTime>0</apiActiveProcessingTime>
<apexProcessingTime>0</apexProcessingTime>
</jobInfo>
URL : https://ap1.salesforce.com/services/async/34.0/job/75090000002tCVOAA2
<?xml version="1.0" encoding="UTF-8"?>
<jobInfo xmlns="http://www.force.com/2009/06/asyncapi/dataload">
<state>Closed</state>
</jobInfo>
Response :
<?xml version="1.0" encoding="UTF-8"?><jobInfo
xmlns="http://www.force.com/2009/06/asyncapi/dataload">
<id>75090000002tCVOAA2</id>
<operation>upsert</operation>
<object>Object1__c</object>
<createdById>00590000003i6nuAAA</createdById>
<createdDate>2015-07-03T12:22:25.000Z</createdDate>
<systemModstamp>2015-07-03T12:22:25.000Z</systemModstamp>
<state>Closed</state>
<externalIdFieldName>Email__c</externalIdFieldName>
<concurrencyMode>Parallel</concurrencyMode>
<contentType>CSV</contentType>
<numberBatchesQueued>1</numberBatchesQueued>
<numberBatchesInProgress>0</numberBatchesInProgress>
<numberBatchesCompleted>0</numberBatchesCompleted>
<numberBatchesFailed>0</numberBatchesFailed>
<numberBatchesTotal>1</numberBatchesTotal>
<numberRecordsProcessed>0</numberRecordsProcessed>
<numberRetries>0</numberRetries>
<apiVersion>34.0</apiVersion>
<numberRecordsFailed>0</numberRecordsFailed>
<totalProcessingTime>0</totalProcessingTime>
<apiActiveProcessingTime>0</apiActiveProcessingTime>
<apexProcessingTime>0</apexProcessingTime>
</jobInfo>
Checking Batch Status
string ServerURL = "";
string Request = "";
string response = "";
string batchId = currentBatchId;
ServerURL = CurentServerUrl+"/" + JobId + "/batch/" + batchId;
WriteLog(ServerURL);
Request = "";
Dictionary<string, string> headder = new Dictionary<string, string>();
headder.Add("X-SFDC-Session", sessionId);
WriteLog(Request);
response = HttpClient.dopost(ServerURL, Request, headder, "GET", "");
WriteLog(response);
return response;
Url: https://ap1.salesforce.com/services/async/34.0/job/75090000002tCVOAA2/batch/75190000004FslWAAS
Response :
<?xml version="1.0" encoding="UTF-8"?><batchInfo
xmlns="http://www.force.com/2009/06/asyncapi/dataload">
<id>75190000004FslWAAS</id>
<jobId>75090000002tCVOAA2</jobId>
<state>Queued</state>
<createdDate>2015-07-03T12:22:59.000Z</createdDate>
<systemModstamp>2015-07-03T12:22:59.000Z</systemModstamp>
<numberRecordsProcessed>0</numberRecordsProcessed>
<numberRecordsFailed>0</numberRecordsFailed>
<totalProcessingTime>0</totalProcessingTime>
<apiActiveProcessingTime>0</apiActiveProcessingTime>
<apexProcessingTime>0</apexProcessingTime>
</batchInfo>
Checking Batch Result
return response;
Url: https://ap1.salesforce.com/services/async/34.0/job/75090000002tCVOAA2/batch/75190000004FslWAAS
Response :
<?xml version="1.0" encoding="UTF-8"?><batchInfo
xmlns="http://www.force.com/2009/06/asyncapi/dataload">
<id>75190000004FslWAAS</id>
<jobId>75090000002tCVOAA2</jobId>
<state>Queued</state>
<createdDate>2015-07-03T12:22:59.000Z</createdDate>
<systemModstamp>2015-07-03T12:22:59.000Z</systemModstamp>
<numberRecordsProcessed>0</numberRecordsProcessed>
<numberRecordsFailed>0</numberRecordsFailed>
<totalProcessingTime>0</totalProcessingTime>
<apiActiveProcessingTime>0</apiActiveProcessingTime>
<apexProcessingTime>0</apexProcessingTime>
</batchInfo>
Checking Batch Result
string ServerURL = "";
string Request = "";
string response = "";
string batchId = currentBatchId;
ServerURL = CurentServerUrl+"/" + JobId + "/batch/" + batchId + "/result";
WriteLog(ServerURL);
Request = "";
Dictionary<string, string> headder = new Dictionary<string, string>();
headder.Add("X-SFDC-Session", sessionId);
response = HttpClient.dopost(ServerURL, Request, headder, "GET", "");
WriteLog(response);
return response;
Url: https://ap1.salesforce.com/services/async/34.0/job/75090000002tCVOAA2/batch/75190000004FslWAAS/result
response :
"Id","Success","Created","Error"
"a039000000YArzNAAT","true","false",""
"a039000000YArzOAAT","true","false",""
"a039000000YArzPAAT","true","false",""
"a039000000YArzQAAT","true","false",""
string Request = "";
string response = "";
string batchId = currentBatchId;
ServerURL = CurentServerUrl+"/" + JobId + "/batch/" + batchId + "/result";
WriteLog(ServerURL);
Request = "";
Dictionary<string, string> headder = new Dictionary<string, string>();
headder.Add("X-SFDC-Session", sessionId);
response = HttpClient.dopost(ServerURL, Request, headder, "GET", "");
WriteLog(response);
return response;
response :
"Id","Success","Created","Error"
"a039000000YArzNAAT","true","false",""
"a039000000YArzOAAT","true","false",""
"a039000000YArzPAAT","true","false",""
"a039000000YArzQAAT","true","false",""
Subscribe to:
Posts (Atom)