• stan_sfdc
  • 33 Points
  • Member since 2010

  • Chatter
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
  • 5



I have to call to an external webservice everytime a new account is created. My question is, what is the best way to do so?


I thougt about creating an after create trigger that will invoke the method in the class that was generated from the WSDL import. Would that make sense?


If so, how can I import a class into a trigger to use its methods?


Thanks a lot. Regards,



I have two problems here -
1. When invoking Save, the value of Input Text of "Broadcast Number" is not getting sent to the controller, without removing the <apex:selectList>
2. When click on Next / Previous Page (in pagination); the values are getting reset

VF Page
<apex:page standardController="Commercial__c" extensions="CommercialSchedulerVFPController">

    <apex:form id="myform">
        <apex:sectionHeader subtitle="{!titleValue}" title="Commercial Scheduler"/>
        <!-- Commercial Details Section -->     
        <apex:pageBlock id="detailsBlock" title="Commercial Details">
            <apex:pagemessages />
            <apex:pageBlockButtons location="top">
                    <apex:commandButton action="{!save}" value="Save"/>
                    <apex:commandButton action="{!doCancel}" value="Cancel" immediate="true"/> 
            <apex:pageBlockSection title="Commercial Details"  columns="2">
                <apex:inputField value="{!commercialObj.Name}" required="true"/>
                <apex:inputField value="{!commercialObj.Running_Time_Seconds__c}" required="true"/>
                <apex:inputField value="{!commercialObj.Account__c}"/>
                <apex:inputField value="{!commercialObj.Contracted_Broadcast_Time_Seconds__c}" required="true"/>
                <apex:inputField value="{!commercialObj.Broadcast_Start_Date__c}" required="true"/>
                <apex:outputField value="{!commercialObj.Total_Broadcast_Time_Seconds__c}"/>
                <apex:inputField value="{!commercialObj.Broadcast_Stop_Date__c}" required="true"/>
                <apex:outputField value="{!commercialObj.Broadcasts_Scheduled__c}"/>
        <!-- Broadcast Chart Section -->        
           <apex:pageBlockSection title="Broadcast Chart"  columns="1">
            <apex:chart name="AnnualRecurringRevenue"
                                width="100%" height="200"

                          <apex:axis type="Numeric" position="left" grid="true"                              
                            <apex:chartLabel />

                        <apex:axis type="Category" position="bottom" grid="false"
                            <apex:chartLabel />

                        <apex:barSeries orientation="vertical" axis="left" stacked="false"
        <!-- Timeslots Section -->  
            <apex:pageBlockSection id="pbTimeslot" title="Timeslots" columns="1">
                 <apex:selectList id="selectId" value="{!programGenreValue}" size="1">
                  <apex:actionSupport event="onchange" action="{!getResults}" />  rerender="pbTimeslot,detailsBlock" 
                  <apex:selectOptions value="{!programGenre}"/> 
                <apex:pageBlockTable id="maintable" value="{!timeSlotResults}" var="t" rendered="{!NOT(ISNULL(timeSlotResults))}" width="100%">
                    <apex:column width="20%"  headerValue="Number of Broadcasts">
                        <apex:outputPanel styleClass="requiredInput" layout="block">
                        <apex:outputPanel styleClass="requiredBlock" layout="block"/>
                            <apex:inputText value="{!t.broadcastNumber}" style="width:50px"/>
                    <apex:column width="20%"  headerValue="Program Name">
                        <apex:outputLink value="/{!t.timeSlotObj.Id}" target="_blank">
                        <apex:outputText value="{!t.timeSlotObj.Program_Name__c}">
                    <apex:column width="20%" value="{!t.timeSlotObj.Program_Genre__c}" headerValue="Program Genre"/>
                    <apex:column width="20%" value="{!t.timeSlotObj.Timeslot_Date_Time__c}" headerValue="Timeslot Date/Time"/>
                    <apex:column width="20%" value="{!t.timeSlotObj.Remaining_Commercial_Time_Seconds__c}" headerValue="Remaining Commercial Time (Seconds)"/>
                 <apex:outputPanel >
                     <div align="center">
                    <apex:commandButton disabled="{!!hasprevious}" action="{!First}" value="|< First" immediate="true"/>&nbsp;&nbsp;&nbsp;&nbsp;
                    <apex:commandButton disabled="{!!hasprevious}" action="{!Previous}" value="Previous" immediate="true"/>&nbsp;&nbsp;&nbsp;&nbsp;
                   <apex:outputText >{!IF((pageNumber * size)>noOfRecords, noOfRecords,(pageNumber * size))} of {!noOfRecords}</apex:outputText>&nbsp;&nbsp;&nbsp;&nbsp;
                    <apex:commandButton disabled="{!!hasnext}" action="{!Next}" value="Next" immediate="true"/>&nbsp;&nbsp;&nbsp;&nbsp;
                    <apex:commandButton disabled="{!!hasnext}" action="{!Last}" value="Last >|" immediate="true"/>   


public class CommercialSchedulerVFPController{

    public Commercial__c commercialObj	{get;set;}
    public Integer noOfRecords			{get; set;}
    public Integer noOfBroadcasts 		{get;set;}
    public String programGenreValue 	{get;set;}
    public ApexPages.StandardSetController con{get;set;}
	public DateTime startDate;
    public DateTime endDate;  
    public Integer size {get;set;}
    public String commercialObjId		{get;set;}
    public String titleValue 			{get;set;}

	List<TimeSlotWrapper> timeSlotResults  {get;set;} 

//  Standard Constructor    
    public CommercialSchedulerVFPController(ApexPages.StandardController controller){
       this.commercialObj 	= (Commercial__c)controller.getRecord();
       commercialObjId = ApexPages.currentPage().getParameters().get('id');
       programGenreValue 	= '';
       size = 5; 
       if(commercialObjId == Null || commercialObjId == ''){
        // Represents a New Page 
           commercialObj 		= New Commercial__c();
           titleValue			= 'New Commercial';
        //	 Represents an existing Edit Page	
             commercialObj 			= [SELECT Id,Name,Running_Time_Seconds__c,Account__c,Contracted_Broadcast_Time_Seconds__c,Broadcast_Start_Date__c,Total_Broadcast_Time_Seconds__c,Broadcast_Stop_Date__c,Broadcasts_Scheduled__c 
             					 		  FROM Commercial__c 
             					  		  WHERE id=:commercialObjId
             titleValue			 		= commercialObj.Name;
             Map<Id,Double> timeSlotBroadcastNoMap = fetchExistingTimeslotValue();					   

	public void initStdSetController(){
  //	Change these dates to actuals      
        startDate 		= Date.today();
        endDate 		= Date.today()+14;
        con 			= new ApexPages.StandardSetController(Database.getQueryLocator(getQuery()));
        noOfRecords 	= con.getResultSize();
 //	Method to do a dynamic query based on the selected Genre
 private String getQuery(){
        //	Change these dates to actuals      
        startDate 		= Date.today();
        endDate 		= Date.today()+14;
 			String query = 'SELECT Timeslot_Date_Time__c, Remaining_Commercial_Time_Seconds__c, Program_Name__c, Program_Genre__c'
 			 			 + ' FROM Timeslot__c';
                        // + ' WHERE Timeslot_Date_Time__c >=:Startdate and Timeslot_Date_Time__c <=:Enddate';               																	
            system.debug('@@ programGenreValue @@'+programGenreValue);        	 
        	if(programGenreValue!='' && programGenreValue!='All'){
        		query	+= ' WHERE Program_Genre__c =: programGenreValue '; 
        System.debug('@@ query @@ '+query); 
        return query;
//	This method is used to invoke the list from the VF Page    
    public pageReference getResults(){
    	system.debug('@@ getResults - Start @@');
    	system.debug('@@ getResults - End @@');
    	return null;
  // Methods used for pagination logic
  public Boolean hasNext {
        get {
            return con.getHasNext();

    // indicates whether there are more records before the current page set.
    public Boolean hasPrevious {
        get {
            return con.getHasPrevious();

    // returns the page number of the current page set
    public Integer pageNumber {
        get {
            return con.getPageNumber();

    // returns the first page of records
     public void first() {

     // returns the last page of records
     public void last() {

     // returns the previous page of records
     public void previous() {

     // returns the next page of records
     public void next() {
         system.debug('@@ con @@'+con);
         for (TimeSlotWrapper loopvar : timeSlotResults) {
         	system.debug('@@ timeSlotResults-loopvar @@'+loopvar);

     // returns the PageReference of the original page, if known, or the home page.
     public void cancel() {
 //	This method will Cancel the transaction and redirect to the Object Page without validations    
     public Pagereference doCancel(){
        Schema.Describesobjectresult result = Schema.Sobjecttype.Commercial__c; 
        ApexPages.Pagereference cancelPg = new PageReference('/' + result.getKeyPrefix() + '/o');
        cancelPg .setRedirect(true);
        return cancelPg ;
 //	This method constructs the picklist of Program Genre used for filtering the table     
    public List<SelectOption> getProgramGenre(){
        List<SelectOption> options                  = new List<SelectOption>();
        Schema.DescribeFieldResult fieldResult      = Timeslot__c.Program_Genre__c.getDescribe();
        List<Schema.PicklistEntry> ple              = fieldResult.getPicklistValues();
        options.add(new SelectOption('All','All'));

// 		Reading from the object definition to allow dynamic values to be added later        
        for(Schema.PicklistEntry f : ple){
              options.add(new SelectOption(f.getLabel(), f.getValue()));
        system.debug('@@ options @@'+options);
        return options;
//	Fetch existing value of Timeslots for existing 
	public Map<Id,Double> fetchExistingTimeslotValue(){
		system.debug('@@ fetchExistingTimeslotValue - Start @@');
		Map<Id,Double> timeSlotBroadcastNoMap			= new Map<Id,Double>();
		List<Commercial_Slot__c> commercialSlotList 	= [SELECT Timeslot__c, Number_of_Broadcasts__c, Commercial__c 
															FROM Commercial_Slot__c 
															WHERE Commercial__c =: commercialObj.Id
		for(Commercial_Slot__c loopvar: commercialSlotList){
			timeSlotBroadcastNoMap.put(loopvar.Timeslot__c, loopvar.Number_of_Broadcasts__c);
		system.debug('@@ timeSlotBroadcastNoMap @@'+timeSlotBroadcastNoMap);
		system.debug('@@ fetchExistingTimeslotValue - End @@');
		return timeSlotBroadcastNoMap;

//	Invokes the Save operation    
    public PageReference save(){
        system.debug('@@ save - Start @@');
        for (TimeSlotWrapper loopvar : timeSlotResults) {
        	system.debug('@@ loopvar @@'+loopvar);
        	//if (cw.checked)
            //    selectedContacts.add(new ContactListWrapper(cw.serviceContractNotificationObj));
            //    unselectedContacts.add(new ContactListWrapper(cw.serviceContractNotificationObj));   
        system.debug('@@ save - End @@');
        return null;

// This is to capture which numbers were entered i.e. changed the default from 0 to something else
    public List<TimeSlotWrapper> changedTimeSlotRecords {
        get {
            if (changedTimeSlotRecords == null) changedTimeSlotRecords = new List<TimeSlotWrapper>();
            return changedTimeSlotRecords;
	 public List<TimeSlotWrapper> getTimeSlotResults() {
        timeSlotResults 		= new List<TimeSlotWrapper>();
        for (Timeslot__c loopvar : (List<Timeslot__c>)con.getRecords()){
            timeSlotResults.add(new TimeSlotWrapper(loopvar));
		system.debug('@@ timeSlotResults @@'+timeSlotResults);
        return timeSlotResults;
	 // Wrapper Class to hold the Number of Broadcast Schedules
	 public class TimeSlotWrapper {
	    public Integer broadcastNumber {get; set;}
	    public Timeslot__c timeSlotObj { get; set;}
	    public TimeSlotWrapper(){
	        timeSlotObj 			= new Timeslot__c();
	        broadcastNumber			= 0;	
	    public TimeSlotWrapper(Timeslot__c t){
	        timeSlotObj 			= t;
	        broadcastNumber			= 0;


I have trield almost every code and solution from forum still stuck into this challange.
Refactor Components and Communicate with Events
Refactor the input form for camping list items into its own component and communicate with component events.
Replace the HTML form in the campingList component with a new campingListForm component that calls the clickCreateItem JavaScript controller action when clicked.
The campingList component listens for a c:addItemEvent event and executes the action handleAddItem in the JavaScript controller. The handleAdditem method saves the record to the database and adds the record to the items value provider.
The addItemEvent event is of type component and has a Camping_Item__c type attribute named item.
The campingListForm registers an addItem event of type c:addItemEvent.
The campingListFormController JavaScript controller calls the helper's createItem method if the form is valid.
The campingListFormHelper JavaScript helper creates an addItem event with the item to be added and then fires the event. It then resets the newItem value provider with a blank sObjectType of type Camping_Item__c.

I am not pasting entire code as it is too lengthy.

I am trying from past 2 days, many hours ... still no luck.
Tried with every possible solution from Forum and StackExchange tried with fresh Trailhead Org, nothing worked.
with each try .. getting new errors.
Can someone please try the solution in their system and provide it in the comment ssection. That would be a great help.
Thanks in advance,
Do we know of any getting started or how to use material on SAQL ? Its Dev guide everything except how to use it :)



I have a History Object with createdDate as DateTime data type which is in this format 2005-10-08T01:02:03Z

Now my requirement is that i need to get the current time with date in the format 2005-10-08T01:02:03Z and pass it on to the SOQL.


I have tried to dynamically get the current DataTime as shown below

 String str = DateTime.now().format('yyyy-MM-dd\'T\'hh:mm:ss\'z\'');


but the problem is that i cannot assign this string to my created datatime as shown below

FROM Account
WHERE CreatedDate =: str


I have tried to print DateTime.now(), System.now() in the console but they all throw the output in this fashion - YYYY:MM:DD HH:mm::SS. 


Can i please know how do i resolve this or is there any function which can directly fetch me datetime in this format 2005-10-08T01:02:03Z.


Appretiate your help.






I have to call to an external webservice everytime a new account is created. My question is, what is the best way to do so?


I thougt about creating an after create trigger that will invoke the method in the class that was generated from the WSDL import. Would that make sense?


If so, how can I import a class into a trigger to use its methods?


Thanks a lot. Regards,




I'm trying to do a simple query that compares two DATETIME fields on the same record. Here's the query:

SELECT Id FROM Lead WHERE AddressUpdated__c > AccountManagerUpdated__c

Both of these are custom fields (obviously) but I always get this error and for the life of me I can't figure out why:

MALFORMED_QUERY: ... unexpected token: AccountManagerUpdated__c

After much searching and doc flipping I can't seem to find anything that points at what I'm doing wrong...

Message Edited by ccrawford on 06-01-2007 09:30 PM