Tuesday, June 27, 2017
Monday, June 19, 2017
Understanding __c and __r
I will use the Property__c and Broker__c sobjects. When a relationship is created between these two sobjects, the following fields are created in salesforce schema of these objects.
Property__c (child):
global Id Broker__c;
global Broker__c Broker__r;
Broker__c (parent):
global List<Property__c> Properties__r;
Upward traversal: get fields of parent object for a given child object
Downward traversal: get fields of child object for given parent object
Reference: http://11concepts.com/sfdc/blog/understanding-__c-and-__r/
Saturday, June 17, 2017
SOAP UI - TLS 1.0 has been disabled in this organization.Please use TLS 1.1 or higher when connecting to Salesforce using https
Solution:
Step 1: Navigate to C:\Program Files\SmartBear\SoapUI-5.3.0\bin folder.
Step 2: Edit SoapUI-5.2.1.vmoptions file with System admin permission in any text editor.
Step 3: Add following entry and save the file. It will only enable TLS 1.2 protocol.
Step 1: Navigate to C:\Program Files\SmartBear\SoapUI-5.3.0\bin folder.
Step 2: Edit SoapUI-5.2.1.vmoptions file with System admin permission in any text editor.
Step 3: Add following entry and save the file. It will only enable TLS 1.2 protocol.
-Dsoapui.https.protocols=TLSv1.2
Step 4: Close and Re-launch the Soap UI.Creating SOAP Web Service in Apex
Create the apex class and generate its wsdl. Download Partner wsdl as well.
Convert the wsdl files that you have downloaded to jar files using the command below:
Using SoapUI, get the sessionId from partner wsdl:
Enter the sessionId value in custom apex class wsdl. Check the below request and response:
You can call this web service using Java like below:
Refer this link to set up Java developer environment:
https://developer.salesforce.com/docs/atlas.en-us.salesforce_developer_environment_tipsheet.meta/salesforce_developer_environment_tipsheet/salesforce_developer_environment_overview.htm
global class MathOperations
{
webservice static Integer getSum (Integer a, Integer b)
{
return a + b;
}
}
Convert the wsdl files that you have downloaded to jar files using the command below:
java -classpath force-wsc-40.1.1.jar;rhino-1.7.7.1.jar;ST-4.0.8.jar;C:\Java\jdk1.8.0_121\lib\tools.jar com.sforce.ws.tools.wsdlc partner.wsdl partner_stub.jar
Using SoapUI, get the sessionId from partner wsdl:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:partner.soap.sforce.com">
<soapenv:Header>
</soapenv:Header>
<soapenv:Body>
<urn:login>
<urn:username>username</urn:username>
<urn:password>password</urn:password>
</urn:login>
</soapenv:Body>
</soapenv:Envelope>
Enter the sessionId value in custom apex class wsdl. Check the below request and response:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mat="http://soap.sforce.com/schemas/class/MathOperations">
<soapenv:Header>
<mat:SessionHeader>
<mat:sessionId>00D6A000001Vait!ARwAQPfREKhyBFwVu3F.vFEXYDvLIiR3w8K5hlZvemfv_vFPGECj.QLj3HXsOVFQzVb7OQAG.T9QFWqUzh5P0PP0rPhASOdo</mat:sessionId>
</mat:SessionHeader>
</soapenv:Header>
<soapenv:Body>
<mat:getSum>
<mat:a>5</mat:a>
<mat:b>8</mat:b>
</mat:getSum>
</soapenv:Body>
</soapenv:Envelope>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://soap.sforce.com/schemas/class/MathOperations">
<soapenv:Body>
<getSumResponse>
<result>13</result>
</getSumResponse>
</soapenv:Body>
</soapenv:Envelope>
You can call this web service using Java like below:
package wsc;
import com.sforce.soap.MathOperations.Connector;
import com.sforce.soap.MathOperations.SoapConnection;
import com.sforce.soap.partner.PartnerConnection;
import com.sforce.ws.ConnectionException;
import com.sforce.ws.ConnectorConfig;
public class SalesforceSoapStarter {
private static final String AUTH_ENDPOINT = "https://login.salesforce.com/services/Soap/u/40.0";
private static final String USERNAME = "username";
private static final String PASSWORD = "password";
public static void main(String[] args) throws ConnectionException {
ConnectorConfig config = new ConnectorConfig();
config.setUsername(USERNAME);
config.setPassword(PASSWORD);
config.setAuthEndpoint(AUTH_ENDPOINT);
PartnerConnection connection = new PartnerConnection(config);
String sessionId = config.getSessionId();
SoapConnection soap = Connector.newConnection("","");
soap.setSessionHeader(sessionId);
System.out.println(soap.getSum(4, 9));
}
}
Refer this link to set up Java developer environment:
https://developer.salesforce.com/docs/atlas.en-us.salesforce_developer_environment_tipsheet.meta/salesforce_developer_environment_tipsheet/salesforce_developer_environment_overview.htm
Tuesday, June 6, 2017
Foreground, setBackground, setStorable, setAbortable
There are some properties that you can set on a server-side action to influence how the framework manages the action while it’s in the queue waiting to be sent to the server.
Foreground and Background Actions
Foreground actions are the default. Multiple queued foreground actions are batched in a single request (XHR) to minimize network traffic. The batching of actions is also known as boxcar’ing, similar to a train that couples boxcars together. The server sends the XHR response to the client when all actions have been processed on the server. If a long-running action is in the boxcar, the XHR response is held until that long-running action completes. Marking an action as background results in that action being sent separately, which avoids it impacting the response time of the other actions.To set an action as a background action, call the
setBackground()
method on the action object in JavaScript.Storable Actions
Enhance your component’s performance by marking actions as storable to quickly show cached data from client-side storage without waiting for a server trip. If the cached data is stale, the framework retrieves the latest data from the server.To mark a server-side action as storable, call
- A storable action might result in no call to the server. Never mark as storable an action that updates or deletes data.
- For storable actions in the cache, the framework returns the cached response immediately and also refreshes the data if it’s stale. Therefore, storable actions might have their callbacks invoked more than once: first with cached data, then with updated data from the server.
setStorable()
on the action in JavaScript code.Abortable Actions
An abortable action in the queue is not sent to the server if the component that created the action is no longer valid, that iscmp.isValid() == false
. A component is automatically destroyed and marked invalid by the framework when it is unrendered. Mark a server-side action as abortable by using the setAbortable() method on the Action object in JavaScript.Mark a server-side action as abortable by using the
setAbortable()
method on the Action object in JavaScript.Let's understand the scenarios using a sample application. Pressing the button under Foreground Action results in 1 batched action from 2 different actions (the 3rd entry), and is then sent to the server; while pressing the button under Background Action results in the action being sent separately (the 1st and 2nd entry) to the server.
Pressing the button under Storable Action for the first time results in one server trip (foreground action). Pressing the button again for couple of times doesn't result in any more server trips, displaying the same cached data from client-side storage as shown below.
Code for this application is provided below.
Subscribe to:
Posts (Atom)