Browse Month: May 2016

Lead Conversion: Order of execution of triggers

On conversion of Lead following is the order of execution of triggers of Account, Opportunity, Contact and Lead:

1) Account Before Trigger
2) Account After Trigger
3) Opportunity Before Trigger
4) Opportunity After Trigger
5) Contact Before Triger
6) Contact After Trigger
7) Lead Before Trigger
8) Lead After Trigger

  • All other processes(validations, workflows,approval process, process builders etc. ) executes as per standard order of execution with these triggers and if any exception occurs throughout this process then the complete transaction is rollback.
  • Execution of triggers of Account,Opportunity and Contact depends on the settings of lead conversion.


Reading Mind Technology


Reading Mind Technology

What if Mind reading turns out to be a reality then days are not too far when our Smartphone will not of any use. Because then people would be able to connect with others through their minds. It is not fake but reality that many scientists have been working towards decoding the mind and thoughts of human.

Researchers and scientists have already achieved the success in understanding the Physical structure and chemical workings of the brain and now they are after solving the mysteries to understand the intent of the human, what people dream about and what makes them psychopath. I would like to throw some light on the kind of researches and inventions that have been done past years which are contributing towards decoding the mind and thoughts.


Researchers from University of California, Berkley have invented a Brain Decoder Device. This brain decoder device is able to analyze what you are thinking based on neuron activity inside the brain. Researchers have invited the tests subjects to read a passage of text out loud and then reading the same passage in their mind and then they compared the brain activity to look for the linked patterns.  If the technique gets further improvised then it can become boon for those who have lost their ability to speak.  And with the power of mind working wonders, we will be able to control the devices such as Smartphone, computers and other devices with our mind. “If you’re reading text in a newspaper or a book, you hear a voice in your own head,” the University’s Brian Pasley told New Scientist. “We’re trying to decode the brain activity related to that voice to create a medical prosthesis that can allow someone who is paralyzed or locked in to speak.” Pasley and his team based their work around the hypothesis that hearing words in our head causes the same kind of brain activity as hearing them spoken. The sophisticated hardware is under developmental stage and requires being more accurate so it can be utilized out of the lab. The subject is observed carefully and algorithms underpinning the system vary from person to person.

Even Japanese researchers are not behind in evolving this technology. They have developed the mind reading device as well that decipher words from brainwaves without them being spoken. They were able to identify the words such as ‘goo’, ‘scissors’ and ‘par’ when spoken in Japanese. They can identify the brain waves related with syllables or letters hence ensuring the possibility of decoding entire words and sentences without the need for any of them being physically spoken. Researchers used a method to listen to the unspoken word called Electroencephalogram or EEG. The technology records the electrical activity from the brain using an array of electrodes on the scalp to detect the brain waves. The team focused on a part of the brain known as Broca’s area, which is thought to be involved in language processing and speech. Lead author Professor Yamazaki Toshimasa, an expert in brain computer interfaces at Kyushu Institute of Technology in Japan’s Fukuoka Prefecture, and his team asked 12 men, women and children to recite a series of words, measuring their brainwaves as they did so. They found each syllable produced a distinct brain wave activity from the initial thought to the actual utterance. Activity could be seen up to two seconds before a word was spoken. By compiling a database of different sounds, the researchers found it is possible to match these brainwave patterns to words, even if they are not spoken.

Not only this, scientists are developing the technique to control the channels on your TV. For this, they are developing headsets that can read your brainwaves to change the channels.

Researchers from Birmingham University have devised a way to verify the person’s identity 2 years ago. The researchers observed the brain signals of 45 volunteers as they read a list of 75 acronyms, such as FBI and DVD, and recorded the brain’s reaction to each group of letters, focusing on the part of the brain associated with reading and recognizing words. Turns out, participants’ brains reacted differently to each acronym — so much so that a computer system was able to identify each volunteer with 94 percent accuracy.

Yukiyasu Kamitani and his team at ATR Computational Neuroscience Laboratories in Kyoto, Japan, have been able to identify what subjects were dreaming about. They use fMRI (functional MRI), which measures brain activity by picking up on the magnetic properties of hemoglobin that vary with blood oxygenation. Scientists have made some startling breakthroughs in reproducing our thoughts on a screen and delving into what motivates us to do the things we do. The subjects are put into fMRI machine and woken up just as they were drifting off. They then reported what they had been dreaming about. A database was created from the information, and using machine-learning algorithm and a visual-imagery decoder, scientists were able to identify what the subjects were dreaming about in subsequent scans.

Can you imagine that your imagination can also be traced on the screen? Participants imagine forming letters and recorded the patterns of their brains made while they did it. Researchers used this information along with the algorithms and translated it into Pixels thus they were able to reconstruct the actual images of the Participants imagination.

fMRI technology has even enabled researchers to understand the People’s reaction towards the specific products without even their need of uttering the words. The company uses fMRI to assess their feelings about products, packaging, advertising, and even smell.

Defense Advanced Research Projects Agency (DARPA) is funding an initiative where they can hack the mind of the veterans and service members and help them in treating their mental illness and addictions.

Since reading mind is taking a shape of reality, there are few things that we should consider from right now and even start researching on it. It is security of your thoughts, your imagination. In the near future, we may have to find the potential way to secure our mind from unwanted access to information that we have in our mind. I do not blame on technology as it has many advantages if used in proper way but I can blame those users who can misuse it. The technologies like fMRI enable the researchers to understand patterns of prefrontal cortex activity before they took the action, were able to decode what they were about to do. That means in future someone can understand our intent even before we perform any action. It will more become spying on our secret thoughts and our thoughts will no longer be private. Our mind is full of innovative ideas and one would never want that someone hack or decode those ideas for their own benefit.

I think it’s a high time that techies & researchers must also start thinking about solution that can secure our valuable mind against misuse of such technologies.

Steps to perform Black Box Testing Methodology

Hi, friends today we will learn Black box testing, this is a very useful testing technique in Software testing. In this technique we give input and get output without knowing how the output is generated. Black box testing is also called as Behavioral testing.

Methods of Black box Testing:

Error Guessing:
In this technique we randomly put any values not fixed values, and get output. It is not the best practice to use Error guessing method always since it may not cover all the scenarios of the black box testing, white box testing then comes to play. In this post I won’t be covering the white box testing methods.

Boundary Value Analysis:
In this testing we provide boundary values. Suppose our Input should be range 1 to 10 then we test it with -1 , 1 , 2 and 9,10,11. It reduces our testing scenarios since values ranging from 1 to 10 will always work in the worst case scenario.

Equivalence partitioning
Equivalence partitioning  is a software testing technique that divides the input data of a software unit into partitions of equivalent data from which test cases can be derived. In principle, test cases are designed to cover each partition at least once.


In the next post I will talk about white box testing methodology. If you like this post share it with your friends.

Abstract class to get a address from current location in Android

public abstract class ReverseGeocoderTask extends AsyncTask<Void, Void, String> {
    private static final String TAG = "ReverseGeocoder";
    private String value = "Checking your location...";

    public abstract void onAddressFound(String address);

    private float mLat;
    private float mLng;
    private Activity mContext;

    public ReverseGeocoderTask(Activity context, Location location) {
        mContext = context;
        mLat = (float) location.getLatitude();
        mLng = (float) location.getLongitude();

    protected void onPreExecute() {
        value = "Searching for address...";

    protected String doInBackground(Void... params) {
        try {
            List<Address> addressList =
                    getFromLocation(mLat, mLng, 1);
            StringBuilder sb = new StringBuilder();
            for (Address addr : addressList) {
                int index = addr.getMaxAddressLineIndex();

            value = sb.toString();
//          Logger.logger("Address Address    " + value);
        } catch (Exception ex) {

            Utilities.showToast(mContext,"Oops! There was an error.Please try to search your location again.");
            value = "Type your location here...";
//            Log.e(TAG, "Geocoder exception: ", ex);
        return value;

    protected void onPostExecute(String location) {

    public static List<Address> getFromLocation(double lat, double lng, int maxResult) {

        List<Address> retList = null;
        String address = String.format(Locale.getDefault(), "$f,%2$f&language=" + Locale.getDefault(), lat, lng);
        URL myurl;
        try {
            myurl = new URL(address);
//            Logger.logger("myurl.......URl...=  ", myurl.toString());
            HttpURLConnection urlConnection = (HttpURLConnection) myurl.openConnection();
            InputStream is = urlConnection.getInputStream();
            if (is != null) {
                int responseCode = urlConnection.getResponseCode();
                if (responseCode == HttpURLConnection.HTTP_OK) {
                    BufferedReader responseReader = new BufferedReader(new InputStreamReader(is));
                    String responseLine;
                    StringBuilder stringBuilder = new StringBuilder();
                    BufferedReader reader = new BufferedReader(
                            new InputStreamReader(is));
                    while ((responseLine = responseReader.readLine()) != null) {

//                    Logger.logger("stringBuilder.......stringBuilder...=  ", stringBuilder.toString());
                    JSONObject jsonObject = new JSONObject();
                    jsonObject = new JSONObject(stringBuilder.toString());

                    retList = new ArrayList<>();

                    Address addr = new Address(Locale.getDefault());
                    if ("OK".equalsIgnoreCase(jsonObject.getString("status"))) {
                        JSONArray results = jsonObject.getJSONArray("results");
//                for (int i = 0; i < results.length(); i++) {
                        JSONObject result = results.getJSONObject(0);

                        String indiStr = result.getString("formatted_address");
//                        Logger.logger("indiStr   " + indiStr);

                        addr.setAddressLine(0, indiStr);

//                }
//                        Logger.logger("retList   " + retList);
                    } else {
//                        throw new IllegalStateException("Method failed: " + response.getStatusLine());
        } catch (IOException | JSONException e) {
        return retList;


How to get last modified field value or previous field value without using Trigger

Today in this post i will explain you how you can get last modified value or previous value without using trigger

  1. Creating aText Field: Create aTEXT (255) field on the Object and name it say: Old Value

    2. Setting up the Workflow Rule + Field Update


  1. Go toSetup | Create | Workflows & Approvals | Workflow Rules
  2. New Rule
  3. Select theObject
  4. ClickNext
  5. Evaluation Criteria:created and every time it’s edited
  6. Rule Criteria:formula evaluates tor true
  7. Fomula:





8. Click Save & Next

9. From underImmediate Workflow Actions, click Add Workflow Action to select Field Update

10. Select the Field to Update: Old Value


11. Select Use a Formula to Set the New Value

12. Formula:



  1. Click Save
  2. Click Done
  3. Click Activate

custom writing

Docusign Salesforce Field Mapping

In this tutorial i am going to explain how we can map docusign fields with salesforce object fields.

Most of the time we need the user data to be writtneback to the salesforce. Once user finish it’s docusign document. At that time we need to create the custom fields on docusign. I hope you already have installed and setup docusign manage package in salesforce .

Login to the docusign and select your uploaded template, you will see the following screen.


You can see there are two sections for field one is standard section which is provided by docusign and other one is custom. We’ll use custom. In order to create (or you can edit existing) custom field click on Edit button in in custom field section. You’ll see the screen for adding a new field.


In order to map field with salesforce you need to check on Relate to salesforce checkbox and select the object and it’s field you want to map. If you want field data enter by user should be writeback to the salesforce then check writeback checkbox. Once you map this field just click on Done button you will see your field in custom field section in docusign. Like this you can add one or more fields(try to map all the fields with the same or related object in salesforce).

Great!!..Now that you have mapped field, the next step is you’ll drag and drop those added custom fields on docusign document. Now send docusign document from salesforce to your email id, finish the document and check if data is writeback or not back to the salesforce.

How To Show Multiple Overlays In Google Maps

Overlays or Markers are quite important in Google Maps. Many times we come across situations when we need to show multiple overlays (markers) in our Map. In this tutorial I will be explaining how we can plot markers at desired locations using Lat Long coordinates.

In my script I have taken source and destination and have shown route with Overlays (Markers) using Lat Lng.


<title>Overlays in Google Maps using HTML & JS</title>

width: 90%;
height: 600px;
border: 1px solid #a0a0a0;


<div id=”map”>

<script src=’’></script>
<script src=’’></script>

var mapObj = new GMaps({
el: ‘#map’,
lat: 19.027069,
lng: 72.838101

//Path is a 2D array storing source to destination coordinates
var path =[
[19.027446, 72.836856],
[19.026452, 72.836491],
[19.025295, 72.835826],
[19.024403, 72.835311],
[19.023023, 72.834731],
[19.021664, 72.833787],
[19.020812, 72.833122],
[19.019737, 72.832242],
[19.020122, 72.831620],
[19.020772, 72.830912],
[19.021056, 72.830676]

var pl = mapObj.drawPolyline({ //to show route

path: path,
strokeColor: ‘#76ff03’,
strokeOpacity: 1,
strokeWeight: 10

mapObj.drawOverlay({ // to show source marker (overlay)
lat: 19.027446,
lng: 72.836856,
content: ‘<div class=”overlay”><img src=”” style=”height:30px;width:30px;” /></div>’

mapObj.drawOverlay({ // to show destination marker (overlay)
lat: 19.021056,
lng: 72.830676,
content: ‘<div class=”overlay”><img src=”” style=”height:30px;width:30px;” /></div>’



We have created Map object and added it’s properties. We are using two functions drawPolyline to show the route and drawOverlay to plot marker. If  you wish you can change the Source and Destination marker image by changing the image URL in drawOverlay function.

You can run this script by copying the code and saving it with a meaningful name with .html extension. After running it on your browser it will look like this.


Since my source and destination were near so I didn’t use Database to store coordinates. I have used simple static array, if you have multiple coordinates then you need to fetch them from database and store them in array.

I hope the code is self explanatory 🙂 If you still find it difficult to understand please drop a comment I will be more than happy to answer it.

Volley Library to make network connection from Android App

Android volley is a networking library was introduced to make networking calls much easier, faster without writing tons of code. By default all the volley network calls works asynchronously, so we don’t have to worry about using asynctask anymore.

Volley comes with lot of features. Some of them are

1. Effective request cache and memory management
2. Cancelling the requests

To use volley library just make below changes in your build.gradle file:

dependencies {
    compile 'com.mcxiaoke.volley:library:1.0.17'

Now add below code to make network calls

StringRequest stringRequest = new StringRequest(Request.Method.POST, url,
        new Response.Listener<String>() {
            public void onResponse(String response) {
               //get response 
        new Response.ErrorListener() {
            public void onErrorResponse(VolleyError error) { 
        }) {
    protected Map<String, String> getParams() {
           // send parameters for post
        return map;


To set connection timeout add below code:
stringRequest.setRetryPolicy(new DefaultRetryPolicy(
RequestQueue requestQueue = Volley.newRequestQueue(context);

Make future payment using Braintree payment gateway

This tutorial is for those who are developing a mobile application and they want to charge a customer(one or more time) in future. In this tutorial I am going to explain backend functionality in details.

Most of the time we need charge to  customer  in future. Some developers may store details in the database but this is not the best way when it comes to security. Fortunately this feature is provided by braintree and stripe payment gateways. Following tutorial will explain you how we can use braintree API.

Before we start a tutorial make sure that you have a braintree(Sandbox/Production) account, if you don’t have an account  you can open your braintree sandbox account from here Sandbox Account. Mobile developers need to install braintree provided sdk from here Mobile SDK
Braintree payment screen

Once you installed SDK successfully you can see the above screen and fields like card Number, Expiration Date and CVV Number which is provided by braintree you don’t need to do any code for that.

If you using sandbox account enter following Card details for testing purpose.

Sandbox Card Number: 4242 4242 4242 4242

Card Exp: Any future expiry month/Year

CVV: 123

When user click “Buy Now” button braintree SDK returns you paymentMethodNonce .  What you’ll do next step. Simply you’ll send paymentMethodNonce to your server through webservice.

Now the actual backend functionality start here.

Suppose you are sending the parameter paymentMethodNonce to the API

In add_card_token.php i will use the method provided by braintree (make sure you have downloaded PHP braintree library if not then click here)


require_once ‘lib/Braintree.php’; //installed braintree php library and include over here





$paymentMethodNonce = $_POST[‘paymentMethodNonce ‘];//Getting parameters from mobile dev

$result = Braintree_Customer::create( array( ‘firstName’ => ‘abc’, ‘lastName’ => ‘efg’, ‘company’ => ‘Nanostuffs’, ‘paymentMethodNonce’ => $paymentMethodNonce ));

$customerid = $result->customer->id; //Store this info into the database

$card_token = $result->customer->paymentMethods[0]->token;//Store this info into the database


The method (Braintree_Customer::create) will returns you all the basic information about the card like expiry, last four…

You will get customer id $result->customer->id and card_token in response $result->customer->paymentMethods[0]->token

You will store this information into the database for that particular customer.

Great, now you are ready to charge a customer in future anytime. Suppose i want to charge that customer now i will use the following method.


require_once ‘lib/Braintree.php’; //installed braintree php library and include over here






$result = Braintree_Transaction::sale(array(  ‘amount’ => ‘100’,

‘paymentMethodToken’ => $customer_id,

‘options’ => [ ‘submitForSettlement’ => True  ] )


if($result->success) {

$transactionId = $result->transaction->id;


$err = ”;

foreach($result->errors->deepAll() AS $error) { $err.= $error->message.” “; }

echo $err;


}catch(Exception $e)



Check and parse proper response returned by braintree. You have charged to the customer successfully. If you run the same method again you can see the charge successfully. Without entering user card details again.

You can achieve this using any sever side langauge. I am familiar with PHP only.

Let us know if this tutorial really help you 🙂

Auto populate related field when lookup filed is selected at run time in visualforce page.

Sometimes we need to populate related field according to selected lookup filed for the form submissions etc. and we need this to be happen at run-time. ex: In visualforce form contains lookup field of Account object and two field like Email,Phone when user select Account lookup the Email and Phone field will be populated  from Account’s email and phone field.

We can achieve this using <apex:actionsupport> tag .

Vf page:

<apex: page standardController=”Test__c” extensions=”AutoPopulateExample “>




<apex:inputField value=”{!Testing.Name__c}” />

<apex:inputField value=”{!Testing.AccountName__c}” >

<apex:actionSupport event =”onchange”  action=”{!autoCal}”   reRender=”accEmail,accPhone”>


<apex:inputField value =”{!Testing.Email__c}”  id=”accEmail” />

<apex::inputField value =”{!Testing.Phone__c}”  id=”accPhone” />


<apex:commandButton value=”Save” action=”{!save}” />





Apex Controller:

public class AutoPopulateExample


public Test__c Testing {get;set;}

public AutoPopulateExample(ApexPages.StandardController controller)


Testing = new Test__c();


//function is called from actionsupport event

public PageReference  autoCal()


Id accId = Testing.AccountName__c;     // collecting account id from visualforce page

List<Account> accLst = [select id,Email,Phone from Account where id=:accid];

Testing.Email__c = accLst[0].Email;      // assigning Account email to visualforce page

Testing.Phone__c= accLst[0].Phone;    // assigning Account phone to  visualforce page







  • 1
  • 2

Need more help?

Hi there, was your problem or query resolved? If not & need more assistance, please do reach out to us at, we'll be more than delighted to help. Nanostuffs has 7+ years of extensive Salesforce & iOS/Android experience.
Holler Box