• Oldwen Adriano
  • NEWBIE
  • 20 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 13
    Questions
  • 17
    Replies
Hello Dev community,

I have an issue with a RESTful callout I'm attempting to make.  The error I get is End of File from server.  Below is my code and the error message.  I'm placing the items in this order:  Page, Controller, Helper class, Web Service SOAP instructions, Page error, dev console error.  Any help is greatly appreciated.
 
<apex:page id="page" controller="WebServiceCallOut" >
	<apex:form id="form" >
		<apex:sectionHeader title="RESTFUL Callout Viewer" />
		
		<apex:pageBlock >
			<apex:pageBlockButtons >
				<apex:commandButton value="Callout" action="{!callout}" id="btnCallout"/>
			</apex:pageBlockButtons>
		
		
			<apex:pageBlockSection columns="1" title="HttpResponse" collapsible="false" >
				<apex:pageBlockSectionItem >
					<apex:outputLabel value="getBody()" />
					{!responseBody}
				</apex:pageBlockSectionItem>
			</apex:pageBlockSection>
		
		</apex:pageBlock>
	</apex:form>
</apex:page>
public with sharing class WebServiceCallOut 
{
	public String responseBody {get;set;}
	
	public String requestEndpoint {get;set;}
	public String requestMethod {get;set;}
	public String requestBody {get;set;}
	
    public WebServiceCallOut()
    {
    	requestEndpoint = myURL.com;
    	requestMethod = 'POST';
    	
    	requestBody = CreateSoapHeader();
    }
    
    public void callout()
    {
		httpResponse res = VerintAPI.callout(requestMethod, requestEndpoint, requestBody);

		responseBody = res.getBody();
	}
	
	public String CreateSoapHeader()
   	{
   		String myServer = 'variable';
   		String myBackup = 'variable';
   		String myPort = ''variable'';
   		String myDevice = 'variable';
   		String myPBX = ''variable'';
   		String myExt = ''variable'';
   
   		String soap = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' +
   		'<soap:Body>' + 
   		'<GetContactId xmlns="http://tempuri.org/">' + 
   		'<request>' +
   		'<Server>' + myServer + '</Server>' + 
        '<BackupServer>' + myBackup + '</BackupServer>' + 
        '<Port>' + myPort + '</Port>' + 
        '<ContactId></ContactId>' +
        '<Extension>' + myExt + '</Extension>' +
        '<AgentPbxId>' + myPBX + '</AgentPbxId>' +
        '<SysDevice>' + myDevice + '</SysDevice>' +
        '<RecordingSource></RecordingSource>' +
        '<Attributes>' +
        '  <AttributeKeyValue>' +
        '    <Key></Key>' +
        '    <Value></Value>' +
        '  </AttributeKeyValue>' +
        '</Attributes>' +
        '</request>' +
        '</GetContactId>' +
        '</soap:Body>' +
        '</soap:Envelope>' ;
        
        return soap;
   	}
}
public with sharing class VerintAPI 
{
    //public static String BASE_URL = '';
    
    
    public static httpResponse callout(String httpMethod, String endpoint, String body)
    {
    	httpRequest req = new httpRequest();
    	
    	req.setMethod(httpMethod);
    	
    	req.setEndpoint(endpoint);
    	
    	req.setHeader('Host', 'verint11-ws.alorica.com');
    	req.setHeader('Content-Type', 'text/xml; charset=utf-8');
    	req.setHeader('Content-Length', string.valueof(body.length()));
    	req.setHeader('SOAPAction', '"http://tempuri.org/GetContactId"');
    	
    	req.setBody(body);
    	    	    	
    	req.setTimeout(120000);
    	
    	httpResponse res = new http().send(req);
    	
    	return res;
    }
}

User-added image
User-added image
User-added image

 
Hello everyone,

I have a Visualforce page included in my account page layout.  Inside that VF page I am running some javascript to update and check conditions of the account.  I am stuck on one particular task.  If a certain condition is true, then I want to close the account tab console that was opened and redirect the user to a VF page that displays whatever info.  When I attempt to run the javascript examples I found, nothing happens. 

I simply took the code from a SF example, but I am unable to make it work...
 
if(Unavailable == true)
    {
        testCloseTab();

    }

function testCloseTab() {
        //First find the ID of the current tab to close it
        sforce.console.getEnclosingTabId(closeSubtab);
    }
    
    var closeSubtab = function closeSubtab(result) {
        //Now that we have the tab ID, we can close it
        var tabId = result.id;
        sforce.console.closeTab(tabId);
    };


I also need some help with the redirect. 

Thank you in advance....
 
Hello,

I am trying to simply call a web service that one of my clients has.  This appears to be rocket science using Salesforce.  All paths have led to failure for this venture thus far.   I have seen all All Star in this community call the WSDL2Apex a crap shoot.  Has anyone in this community successfully called a 3rd party web service?  If so, please tell me how you accomplished this.  I prefer NOT to use the WSDL2Apex as the code that it generates is completely obfuscated and has complexity WITHOUT necessity. 

I understand that I must create a Remote Site setting for the webservice URL and also have the Salesforce IPs whitelisted on the webservice site.

How do I simply create some XML(SOAP envelope), send it over to the web service and get a response!!??????

Any help is deeply appreciated.

Thank you!!
Hello,

I am creating a dynamic InputText and would like to assign the value as it's created, but I am having trouble getting it to work.
 
public String myval {get;set;} 

custResponseString = custResponse[y].CustomerResponse__c;

 Component.Apex.InputText textAns = new Component.Apex.InputText();       
 textAns.value = custResponseString;  
 myval = custResponseString; 
 textAns.expressions.value = '{!myval}';
 questions.childComponents.add(textAns);

I have included some snippets above which shows my process.  Any help is greatly appreciated.

Thank you,
Oldwen
Hello,

I am trying to develop a custom process for questions and answers that wil be managed through a VisualForce page.  I could use some help with this complex issues...

So first, here are my three tables I created.  From the image you can see the tables and the relationships.

User-added image

This next images gives you a visual of what I am trying to achieve on my page and a little bit of basic functionality.

User-added image

So, what I would really like is if we could toss around some ideas on how to make this work.  I was originally thinking a datatable, but a datatable must be bound to a query and doesn't allow for much manipulation THAT I CAN TELL.

I've gotten this far with this, but I'm afraid it may not be in the corretion direction:
 
public Component.Apex.OutputPanel getoutPanel() 
	{
		//Tester, remove next line later
		//Component.Apex.SectionHeader sectionHeader = new Component.Apex.SectionHeader();
		//---------------------------------------------------------------------------------
		
		Component.Apex.OutputPanel outPanel = new Component.Apex.OutputPanel();
		
		Component.Apex.DataTable datatable = new Component.Apex.DataTable(var='row'); 
		
		Lead myLead = [Select Id, Campaign__c from Lead Where Id =: ldObj.Id];
		
		List<Questions__c> myQuestions = new List<Questions__c>();		
		myQuestions = [Select Id, Campaign__c, Question__c, Type_of_Field__c, Order__c from Questions__c Where Campaign__c =: myLead.Campaign__c And Active__c = true Order By Order__c ASC];
		
		vNewLst = database.query('Select Question__c, Type_of_Field__c from Questions__c');
		// Where Campaign__c = ' + myLead.Campaign__c + ' And Active__c = true Order By Order__c ASC
		
		//Type of Field is the type of object --- Type_of_Field__c
		//1 = drop down
		//2 = Text box
		//3 = radio
		//4 = multipick
		//5 = whatever else
		
		
		datatable.expressions.value='{!vNewLst}';
		
		list<String> displayFieldLst= new list<String>{'Question__c','Type_of_Field__c'};
		
		Component.Apex.column clm;
		
		Component.Apex.OutputText outText;
		
		for(string s: displayFieldLst)
		{
			clm = new Component.Apex.column(headerValue= '' + s + ''); 
			
			outText = new Component.Apex.OutputText();
			
			outText.expressions.value = '{!row[\'' + s + '\']}';
			
			clm.childComponents.add( outText );
			
			datatable.childComponents.add( clm );
		}
		//--------------------------------------------------------------------------------------
		
		outPanel.childComponents.add( datatable );
		 
		return outPanel;
			
		//--------------------------------------------------------------------------------------	
		//Select q.Type_of_Field__c, q.Question__c, q.Order__c, q.Id, q.Campaign__c, q.Active__c From Questions__c q	
	}

Thank you in advance for any advice or help with this.
 
Hello,

I am following a simple sample from https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_extension.htm

My code looks like this:
public with sharing class LeadController
{
	private final Lead ldObj;
	//public Lead ldObj{get;set;}
	
	public LeadController(ApexPages.StandardController controller)
	{
		//Fetching the Current Lead Record
		this.ldObj = (Lead)controller.getRecord();
	}
	
	public Component.Apex.SectionHeader getoutPanel() 
	{
		date dueDate = date.newInstance(2011, 7, 4);
		
		boolean overdue = date.today().daysBetween(dueDate) < 0;
		
		Component.Apex.SectionHeader sectionHeader = new Component.Apex.SectionHeader();
		
		if (overdue) 
		{
			sectionHeader.title = 'This Form Was Due On ' + dueDate.format() + '!' + ldObj.FirstName;
			return sectionHeader;
		}
		else
		{
			sectionHeader.title = 'Form Submission';
			return sectionHeader;
		}
	}
}

When I run this, I get the following error:

Content cannot be displayed: SObject row was retrieved via SOQL without querying the requested field: Lead.FirstName

Can anyone please assist me with this?

Thank you in advance.....
 
Could someone please give me a hand writing a test class for this class below?

-----------------------------------------------------------------
global class ControllerGetNext {

List<Task> tList = new List<Task>();

List<wrapper> lstw = new List<wrapper>();

List<wrapper> lstwPage = new List<wrapper>();

//----------------------------------------------------------

//Campaign

List<Campaign__c> cList = new List<Campaign__c>();

public string userselected{get;set;} //I have it declared here as a public variable in the controller

public List<selectOption> useroptions{get;set;}

//----------------------------------------------------------

public ControllerGetNext()

{

// integer nextcount=0;

nextvisible = false;

previsible = true;

page=0;

system.debug('nextvisible=='+nextvisible);

//----------------------------------------------------------

//Campaign

//When the controller instatiates this is called as expected.

useroptions = new list<selectoption>();

cList = [Select ID, Campaign_Name__c from Campaign__c];

for(integer i=0; i < cList.size(); i++)

{

useroptions.add(new SelectOption(cList[i].ID, cList[i].Campaign_Name__c));

}

//----------------------------------------------------------

}

Contact cContact;

Lead lLead;

public List<wrapper> lstWrapperString{

get{return getTasks();}

}

//lstWrapperString

//getTasks

Public List<wrapper> getTasks()

{

lstw.clear();

tList = [Select ID, Subject, ActivityDate, Due_Time__c, Description, WhoID from Task where OwnerId =: UserInfo.getUserId() And Status != 'Completed']; //All of the users tasks

if(!tList.isEmpty())

{

for(integer i=0; i < tList.size(); i++) //Loop thru the tasks and add to list

{

string strPhone = '';

string LeadName = '';

decimal iAttepmts = 0;

try

{

cContact = [SELECT Phone FROM Contact WHERE Id = : tList[i].WhoID]; //The phone is in the contact object which is related to the Lead

strPhone = cContact.Phone;

}

catch(exception e)

{

strPhone = 'Not Provided';

}

try

{

lLead = [SELECT Name, Attempts__c FROM Lead WHERE Id = : tList[i].WhoID];

LeadName = lLead.Name;

iAttepmts = lLead.Attempts__c;

}

catch(exception e)

{

LeadName = 'Not Provided';

iAttepmts = 0;

}

if(iAttepmts < 20) //Business rule for less than 20 attemps.

{

lstw.add(new wrapper(tList[i].ID, LeadName, tList[i].ActivityDate, tList[i].Due_Time__c, tList[i].Description, strPhone));

}

}

}

return lstw;

}

//*******************************************************************************************************

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

//Create my wrapper class... like an ENUM

Public class wrapper

{

public string tID{get;set;}

public string tSubject{get;set;}

public date tActivityDate{get;set;}

public string tDueTime{get;set;}

public string tDescription{get;set;}

public string tPhone{get;set;}

//Constructor

public wrapper(string tID, string tSubject, date tActivityDate, string tDueTime, string tDescription, string tPhone)

{

this.tID = tID;

this.tSubject = tSubject;

this.tActivityDate = tActivityDate;

this.tDueTime = tDueTime;

this.tDescription = tDescription;

this.tPhone = tPhone;

}

}

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

//***********************************************************

//Page navigation actions

//***********************************************************

public integer page=0;

public boolean exfor = true;

public integer nextcount=0;

public List<integer> previouscount = new Integer[100];

public boolean previsible{get;set;}

public boolean nextvisible{get;set;}

public pagereference NextPage()

{

page ++;

exfor = true;

lstwPage = getTasks();

return null;

}

public pagereference previousPage()

{

page--;

nextcount = previouscount.get(page);

system.debug('nextcount'+nextcount);

exfor = true;

lstwPage = getTasks();

return null;

}

//**********************************************************

webService static String GetNextProcess(string ddlCampaignParam) {

//Lead variable used to assign it

Lead assignLead = null;

boolean foundLead = false;

Area_Code__c myTimeZone;

User myUser;

string strLead;

string workPhone;

string myArea;

string strTimeZone;

//Twice in one day variables

Date callDate1;

Date callDate2;

boolean setDate1 = false;

boolean setDate2 = false;

Campaign__c myCamp;

try

{

//Lets get the ID for the dserv user to be used in our query

myUser = [Select Id from User Where Alias = 'dserv'];

//Lets get the name of the Campaign

myCamp = [Select Campaign_Name__c from Campaign__c Where ID =: ddlCampaignParam];

//return 'Error: User name is: ' + UserInfo.getUserId();

//****************************************************************************

//Rule #1 : Pull all the leads that have not been called 4 times or more yet and order then from least to greatest.

//****************************************************************************

list<Lead> lstLeadToAssign = [Select Id, Phone, Lead_Start_Time__c, Lead_End_Time__c from Lead Where (Attempts__c < 5 Or Attempts__c = null) And Final_Flag__c != true And PCB_Flag__c != true And OwnerId =: myUser.Id And Campaign__c =: myCamp.Campaign_Name__c Order By Attempts__c ASC Limit 50];

//return 'Error: Lead size is : ' + lstLeadToAssign.size();

if(lstLeadToAssign.IsEmpty() == false)

{

for(integer i=0; i < lstLeadToAssign.size(); i++)

{

try

{

//----------------------------------------------------------------

//Get the phone num so we can check timezone for call availability against area code table.

//-----------------------------------------------------------------

try

{

workPhone = lstLeadToAssign[i].Phone;

//return 'Error: I got here after phone' + workPhone;

myArea = workPhone.substring(1, 4); //assumes the format is (210)

//return 'Error: I got here ';

}

catch(exception e)

{

continue;

}

try

{

myTimeZone = [Select TimeZone__c from Area_Code__c Where Name =: myArea];

strTimeZone = myTimeZone.TimeZone__c;

}

catch(exception e)

{

return 'Error: No Time Zone info in Area code table -- ' + e;

}

//****************************************************************************

//Rule #2 : Check to make sure that lead is in a callable time zone.

//****************************************************************************

if(AllowedZone(strTimeZone) == true)

{

//return 'Error: I got here';

foundLead = true;

strLead = lstLeadToAssign[i].Id;

//***************************************************************************************

//Rule- only twice in one day : Check to make sure.

//***************************************************************************************

if(lstLeadToAssign[i].Lead_Start_Time__c != null)

{

callDate1 = lstLeadToAssign[i].Lead_Start_Time__c;

if(callDate1 == date.today())

{

//This means, they have been called once today already. So we will check to see if they've been called twice.

if(lstLeadToAssign[i].Lead_End_Time__c != null)

{

callDate2 = lstLeadToAssign[i].Lead_End_Time__c;

if(callDate2 == date.today())

{

//They have already been called twice today so we move on to the next lead.

foundLead = false;

}

else

{

setDate2 = true;

}

}

else

{

setDate2 = true;

setDate1 = false;

}

}

else

{

setDate1 = true;

}

}

else

{

//If Date from Start time was null, then we will set this as our first date.

setDate1 = true;

}

//***************************************************************************************

}

//If lead was found lets go ahead and assign it to the user and and return it and end the process.

if(foundLead == true)

{

assignLead = [Select Id, Lead_Start_Time__c, Attempts__c, Lead_End_Time__c from Lead Where Id =: strLead for update];

try

{

assignLead.OwnerId = UserInfo.getUserId();

//return 'Error: Lead.OwnerId - ' + assignLead.OwnerId;

}

catch(exception e)

{

return 'Error: Could not find your user information!';

}

//***************************************************************************

//Assign our 24 hour period variables

//***************************************************************************

try

{

if(setDate1 == true)

{

assignLead.Lead_Start_Time__c = date.today();

}

if(setDate2 == true)

{

assignLead.Lead_End_Time__c = date.today();

}

}

catch(exception e)

{

return 'Error: On 24 hour date reference! - ' + e;

}

//***************************************************************************

if(assignLead.Attempts__c == null)

{

assignLead.Attempts__c = 1;

}

else

{

assignLead.Attempts__c = assignLead.Attempts__c + 1;

}

update assignLead;

return strLead;

}

}

catch(exception e)

{

return 'Error: inside the last lead found!' + e;

}

}

}

}

catch(exception e)

{

return 'Error: Currently, there is no Lead to assign!';

}

return 'Error: Currently, there is no Lead to assign!';

}

//Function to determine which timezones are currently allowed for calling

public static boolean AllowedZone(string myZone)

{

//return true;

DateTime myDate = DateTime.Now(); //Since the server lives in the EST timezone, you will get an EST time

Integer myStart = 9; //Calls start at 9am

Integer myEnd = 16; //Cannot call later than 5pm

Integer myHour = myDate.Hour(); //Get the current hour.

//Adjust the hour based on the time zone that was passed. EST is the base time zone.

if(myZone == 'CST')

{

myHour = myHour - 1;

}

if(myZone == 'MST')

{

myHour = myHour - 2;

}

if(myZone == 'PST')

{

myHour = myHour - 3;

}

if(myHour < myStart || myHour > myEnd)

{

return false;

}

else

{

return true;

}

}

}
--------------------------------------------------------------------------------------------------------------------------
Hello,

Can someone please help me?  My class does not appear in the test results for Eclipse.  My class is called ControllerGetNext.cls

User-added image

Hello,

Is Mail Merge a utility I can use to send emails thru triggers or code?  Or is this just a wysiwyg interface to send a one time email based on templates I create?  In a nutshell, I need to create a trigger that sends an email after a record is updated and incorporate fields from my object into the email.

Thank you,
Oldwen

 

I am trying to get the selected value from my drop down list on my Visual Force page. 

Here is my page code:
User-added image

Here is my Apex code:

User-added image

What I would like to do is something simple like this:

public myFunction()
{
     string myDDLvalue = get the DDL value

     use my DDLvalue
}
----------------------------------------------
Any help is deeply appreciated!!
Here is my code example:
global class ControllerGetNext { 

     webService static String GetNextProcess() {

           if(AllowedZone(strTimeZone) == true)
		        	{
		        		foundLead = true;
		        		strLead = lstLeadToAssign[i].Id;
		        	}

     }

     public boolean AllowedZone(string myZone)
    {
           //Some code
           return true;
     }
}
This code seems pretty straight forward.  I have a class and then I created a public function within that class.  I try to consume the function within another function of my class and I get the error about incorrect signature.

Can anyone help me with this?
 
Hello... I am trying to write a simple query which uses 2 tables that are related via the WhoID.  Can someone please help me understand why this won't work??

Didn't understand relationship 'Contact' in field path

Select ID, Subject, ActivityDate, Due_Time__c, Description, Contact.Phone from Task

The Contact object has a related field Task using the WhoID

User-added image
Need some assistance with a Wrapper class on a VS pageI am attempting to create a VF page using a wrapper class, but I keep running into errors.  I have broken down my attempt to the most basic level to simply try to gain understanding.

Here is my class:

global class ControllerGetNext {

//Our collection of the class/wrapper objects Tasks

public List taskList {get; set;}

//This method uses a simple SOQL query to return a List of Tasks

public List getTasks()

{

if(taskList == null)

{

taskList = new List();

for(Task t: [Select ID, Subject, ActivityDate, Due_Time__c, Description from Task])

{

// As each contact is processed we create a new Task object and add it to the taskList

taskList.add(t);

}

}

return taskList;

}

// This is our wrapper/container class. A container class is a class, a data structure, or an abstract data type whose instances are collections of other objects.

//In this example a wrapper class contains both the standard salesforce object Contact and a Boolean value

public class tTask

{

public Task tTask {get; set;}

//This is the contructor method. When we create a new tTask object we pass a Task that is set to the t property. We also set the selected value to false

public tTask(Task t) {

tTask = t;

}

}

}

//////////////////////////////////////////////////////////////////////////////
Here is my VF page
/////////////////////////////////////////////////////////////////////////////
















Lead Name












 
Hello,

I am creating a dynamic InputText and would like to assign the value as it's created, but I am having trouble getting it to work.
 
public String myval {get;set;} 

custResponseString = custResponse[y].CustomerResponse__c;

 Component.Apex.InputText textAns = new Component.Apex.InputText();       
 textAns.value = custResponseString;  
 myval = custResponseString; 
 textAns.expressions.value = '{!myval}';
 questions.childComponents.add(textAns);

I have included some snippets above which shows my process.  Any help is greatly appreciated.

Thank you,
Oldwen
Could someone please give me a hand writing a test class for this class below?

-----------------------------------------------------------------
global class ControllerGetNext {

List<Task> tList = new List<Task>();

List<wrapper> lstw = new List<wrapper>();

List<wrapper> lstwPage = new List<wrapper>();

//----------------------------------------------------------

//Campaign

List<Campaign__c> cList = new List<Campaign__c>();

public string userselected{get;set;} //I have it declared here as a public variable in the controller

public List<selectOption> useroptions{get;set;}

//----------------------------------------------------------

public ControllerGetNext()

{

// integer nextcount=0;

nextvisible = false;

previsible = true;

page=0;

system.debug('nextvisible=='+nextvisible);

//----------------------------------------------------------

//Campaign

//When the controller instatiates this is called as expected.

useroptions = new list<selectoption>();

cList = [Select ID, Campaign_Name__c from Campaign__c];

for(integer i=0; i < cList.size(); i++)

{

useroptions.add(new SelectOption(cList[i].ID, cList[i].Campaign_Name__c));

}

//----------------------------------------------------------

}

Contact cContact;

Lead lLead;

public List<wrapper> lstWrapperString{

get{return getTasks();}

}

//lstWrapperString

//getTasks

Public List<wrapper> getTasks()

{

lstw.clear();

tList = [Select ID, Subject, ActivityDate, Due_Time__c, Description, WhoID from Task where OwnerId =: UserInfo.getUserId() And Status != 'Completed']; //All of the users tasks

if(!tList.isEmpty())

{

for(integer i=0; i < tList.size(); i++) //Loop thru the tasks and add to list

{

string strPhone = '';

string LeadName = '';

decimal iAttepmts = 0;

try

{

cContact = [SELECT Phone FROM Contact WHERE Id = : tList[i].WhoID]; //The phone is in the contact object which is related to the Lead

strPhone = cContact.Phone;

}

catch(exception e)

{

strPhone = 'Not Provided';

}

try

{

lLead = [SELECT Name, Attempts__c FROM Lead WHERE Id = : tList[i].WhoID];

LeadName = lLead.Name;

iAttepmts = lLead.Attempts__c;

}

catch(exception e)

{

LeadName = 'Not Provided';

iAttepmts = 0;

}

if(iAttepmts < 20) //Business rule for less than 20 attemps.

{

lstw.add(new wrapper(tList[i].ID, LeadName, tList[i].ActivityDate, tList[i].Due_Time__c, tList[i].Description, strPhone));

}

}

}

return lstw;

}

//*******************************************************************************************************

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

//Create my wrapper class... like an ENUM

Public class wrapper

{

public string tID{get;set;}

public string tSubject{get;set;}

public date tActivityDate{get;set;}

public string tDueTime{get;set;}

public string tDescription{get;set;}

public string tPhone{get;set;}

//Constructor

public wrapper(string tID, string tSubject, date tActivityDate, string tDueTime, string tDescription, string tPhone)

{

this.tID = tID;

this.tSubject = tSubject;

this.tActivityDate = tActivityDate;

this.tDueTime = tDueTime;

this.tDescription = tDescription;

this.tPhone = tPhone;

}

}

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

//***********************************************************

//Page navigation actions

//***********************************************************

public integer page=0;

public boolean exfor = true;

public integer nextcount=0;

public List<integer> previouscount = new Integer[100];

public boolean previsible{get;set;}

public boolean nextvisible{get;set;}

public pagereference NextPage()

{

page ++;

exfor = true;

lstwPage = getTasks();

return null;

}

public pagereference previousPage()

{

page--;

nextcount = previouscount.get(page);

system.debug('nextcount'+nextcount);

exfor = true;

lstwPage = getTasks();

return null;

}

//**********************************************************

webService static String GetNextProcess(string ddlCampaignParam) {

//Lead variable used to assign it

Lead assignLead = null;

boolean foundLead = false;

Area_Code__c myTimeZone;

User myUser;

string strLead;

string workPhone;

string myArea;

string strTimeZone;

//Twice in one day variables

Date callDate1;

Date callDate2;

boolean setDate1 = false;

boolean setDate2 = false;

Campaign__c myCamp;

try

{

//Lets get the ID for the dserv user to be used in our query

myUser = [Select Id from User Where Alias = 'dserv'];

//Lets get the name of the Campaign

myCamp = [Select Campaign_Name__c from Campaign__c Where ID =: ddlCampaignParam];

//return 'Error: User name is: ' + UserInfo.getUserId();

//****************************************************************************

//Rule #1 : Pull all the leads that have not been called 4 times or more yet and order then from least to greatest.

//****************************************************************************

list<Lead> lstLeadToAssign = [Select Id, Phone, Lead_Start_Time__c, Lead_End_Time__c from Lead Where (Attempts__c < 5 Or Attempts__c = null) And Final_Flag__c != true And PCB_Flag__c != true And OwnerId =: myUser.Id And Campaign__c =: myCamp.Campaign_Name__c Order By Attempts__c ASC Limit 50];

//return 'Error: Lead size is : ' + lstLeadToAssign.size();

if(lstLeadToAssign.IsEmpty() == false)

{

for(integer i=0; i < lstLeadToAssign.size(); i++)

{

try

{

//----------------------------------------------------------------

//Get the phone num so we can check timezone for call availability against area code table.

//-----------------------------------------------------------------

try

{

workPhone = lstLeadToAssign[i].Phone;

//return 'Error: I got here after phone' + workPhone;

myArea = workPhone.substring(1, 4); //assumes the format is (210)

//return 'Error: I got here ';

}

catch(exception e)

{

continue;

}

try

{

myTimeZone = [Select TimeZone__c from Area_Code__c Where Name =: myArea];

strTimeZone = myTimeZone.TimeZone__c;

}

catch(exception e)

{

return 'Error: No Time Zone info in Area code table -- ' + e;

}

//****************************************************************************

//Rule #2 : Check to make sure that lead is in a callable time zone.

//****************************************************************************

if(AllowedZone(strTimeZone) == true)

{

//return 'Error: I got here';

foundLead = true;

strLead = lstLeadToAssign[i].Id;

//***************************************************************************************

//Rule- only twice in one day : Check to make sure.

//***************************************************************************************

if(lstLeadToAssign[i].Lead_Start_Time__c != null)

{

callDate1 = lstLeadToAssign[i].Lead_Start_Time__c;

if(callDate1 == date.today())

{

//This means, they have been called once today already. So we will check to see if they've been called twice.

if(lstLeadToAssign[i].Lead_End_Time__c != null)

{

callDate2 = lstLeadToAssign[i].Lead_End_Time__c;

if(callDate2 == date.today())

{

//They have already been called twice today so we move on to the next lead.

foundLead = false;

}

else

{

setDate2 = true;

}

}

else

{

setDate2 = true;

setDate1 = false;

}

}

else

{

setDate1 = true;

}

}

else

{

//If Date from Start time was null, then we will set this as our first date.

setDate1 = true;

}

//***************************************************************************************

}

//If lead was found lets go ahead and assign it to the user and and return it and end the process.

if(foundLead == true)

{

assignLead = [Select Id, Lead_Start_Time__c, Attempts__c, Lead_End_Time__c from Lead Where Id =: strLead for update];

try

{

assignLead.OwnerId = UserInfo.getUserId();

//return 'Error: Lead.OwnerId - ' + assignLead.OwnerId;

}

catch(exception e)

{

return 'Error: Could not find your user information!';

}

//***************************************************************************

//Assign our 24 hour period variables

//***************************************************************************

try

{

if(setDate1 == true)

{

assignLead.Lead_Start_Time__c = date.today();

}

if(setDate2 == true)

{

assignLead.Lead_End_Time__c = date.today();

}

}

catch(exception e)

{

return 'Error: On 24 hour date reference! - ' + e;

}

//***************************************************************************

if(assignLead.Attempts__c == null)

{

assignLead.Attempts__c = 1;

}

else

{

assignLead.Attempts__c = assignLead.Attempts__c + 1;

}

update assignLead;

return strLead;

}

}

catch(exception e)

{

return 'Error: inside the last lead found!' + e;

}

}

}

}

catch(exception e)

{

return 'Error: Currently, there is no Lead to assign!';

}

return 'Error: Currently, there is no Lead to assign!';

}

//Function to determine which timezones are currently allowed for calling

public static boolean AllowedZone(string myZone)

{

//return true;

DateTime myDate = DateTime.Now(); //Since the server lives in the EST timezone, you will get an EST time

Integer myStart = 9; //Calls start at 9am

Integer myEnd = 16; //Cannot call later than 5pm

Integer myHour = myDate.Hour(); //Get the current hour.

//Adjust the hour based on the time zone that was passed. EST is the base time zone.

if(myZone == 'CST')

{

myHour = myHour - 1;

}

if(myZone == 'MST')

{

myHour = myHour - 2;

}

if(myZone == 'PST')

{

myHour = myHour - 3;

}

if(myHour < myStart || myHour > myEnd)

{

return false;

}

else

{

return true;

}

}

}
--------------------------------------------------------------------------------------------------------------------------

Hello,

Is Mail Merge a utility I can use to send emails thru triggers or code?  Or is this just a wysiwyg interface to send a one time email based on templates I create?  In a nutshell, I need to create a trigger that sends an email after a record is updated and incorporate fields from my object into the email.

Thank you,
Oldwen

 

I am trying to get the selected value from my drop down list on my Visual Force page. 

Here is my page code:
User-added image

Here is my Apex code:

User-added image

What I would like to do is something simple like this:

public myFunction()
{
     string myDDLvalue = get the DDL value

     use my DDLvalue
}
----------------------------------------------
Any help is deeply appreciated!!
Need some assistance with a Wrapper class on a VS pageI am attempting to create a VF page using a wrapper class, but I keep running into errors.  I have broken down my attempt to the most basic level to simply try to gain understanding.

Here is my class:

global class ControllerGetNext {

//Our collection of the class/wrapper objects Tasks

public List taskList {get; set;}

//This method uses a simple SOQL query to return a List of Tasks

public List getTasks()

{

if(taskList == null)

{

taskList = new List();

for(Task t: [Select ID, Subject, ActivityDate, Due_Time__c, Description from Task])

{

// As each contact is processed we create a new Task object and add it to the taskList

taskList.add(t);

}

}

return taskList;

}

// This is our wrapper/container class. A container class is a class, a data structure, or an abstract data type whose instances are collections of other objects.

//In this example a wrapper class contains both the standard salesforce object Contact and a Boolean value

public class tTask

{

public Task tTask {get; set;}

//This is the contructor method. When we create a new tTask object we pass a Task that is set to the t property. We also set the selected value to false

public tTask(Task t) {

tTask = t;

}

}

}

//////////////////////////////////////////////////////////////////////////////
Here is my VF page
/////////////////////////////////////////////////////////////////////////////
















Lead Name