Java Code Data Policy Examples/Retrieve and Verify Prospect Fields Code Sample

Java Code Data Policy Examples/Retrieve and Verify Prospect Fields Code Sample

From LongJump Support Wiki

Java Code Data Policy Examples/Retrieve and Verify Prospect Fields Code Sample
Jump to: navigation, search

This code is intended for use as part of a Data Policy. It is a complex example of the use of Java code to take a series of actions, each based on the previous code section. For information on the use of this code sample, see: Retrieve and Verify Prospect Fields on Convert to Account.

import com.platform.api.*;


public class DataPolicyExamples {

  public void verifyProspectFields(Parameters requestParams) {
    Boolean errorCheck = false;

    String error = "Retrieving values from Prospect on convert to account!";
    //Retrieve prospect name
    String name = requestParams.get("name");
    //Check for name being null
    if( (name.equals(null)) || (name.equals("")) )
    {
       Functions.debug("Name of the prospect: " + name);
       //Add to error string
       error += "Name is null" ;
       errorCheck = true;
    }
    //Retrieve phone number of the prospect
    String phone = requestParams.get("phone");
    //Check for phone value being null
    if( (phone.equals(null)) || (phone.equals("")) )
    {
       Functions.debug("Name of the prospect: " + phone);
       //Add to error string
       error += "Phone is null" ;
       errorCheck = true;
    }
    //Retrieve street from the prospect record being converted
    String street = requestParams.get("street");
    //Check for city value being null
    if( (street.equals(null)) || (street.equals("")))
    {
      //Log to the debug log
      Functions.debug("Prospect Street : " + street);
      //Add to error string
      error += "Street is null";
      errorCheck = true;
    }
    //Retrieve description
    String city = requestParams.get("city");
    //Check for desc being null
    if( (city.equals(null)) || (city.equals("")) )
    {
       Functions.debug("City: " + city);
       //add to error string
       error += "City is null";
       errorCheck = true;
    }

    //errorCheck is true if there is an error
    if(errorCheck)
    {
       Functions.debug(error);      // Log the error message
       Functions.throwError(error); // Display it in a dialog
    }
  } // end method
}// end class
Personal tools