• Neeraj_Chauriya
  • NEWBIE
  • 195 Points
  • Member since 2013

  • Chatter
    Feed
  • 6
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 28
    Replies

In my trigger i would like to calculate the number of months between two date.

 

For Example if the date format is (DAY/MONTH/YEAR):

START DATE : 07/10/2013

END DATE: 12/01/2014

 

Number Months=4

because (07/01/2014) plus 1 month for the 5 days

I've tried with many examples, but nothing.

 

Please can you help me?

Thanks in advantage for any advice.

BR

Hi guys

 

i have three lists of different objects in my controller and i have to retrieve values from that lists and display it in VF page which is rendered as pdf.

 

but when i try to use dataTable or PageBlockSection it doesnot show anyvalue and when i use <apex:repeat> then it displays value but for two times i know because repeat works like for loop for display records but how i can display the field values can anyone please tell me exact sytnax? i am using the following code now but its not showing

<apex:dataTable value="{!accounts}" var="a">

<tr>
<td>ROC No. <span class="wrapper" style="padding: -1px 0 0 90px; border:solid #000 1px;"><input type="text" style="height:20px;" size="10" />{!a.ROC_No__c}</span>JKKP Reg. No.<span class="wrapper" style="padding: 4px 0 0 72px; border:solid #000 1px;"><input type="text" style="height:15px;" size="20"/></span></td>
<td style="background-color:#cecece;"></td>
<td rowspan="4"></td>
</tr>

</apex:dataTable>

 

Please Help!

As you can see in my code below I've hard-coded a query in my AggregateResultIterator class and it works great.  However, I'd like to modify the code so that I can pass the query into the main BatchActivityGrouping class, then pass it to the AggregateResultIterable class, then finally pass the query to the AggregateResultIterator constructor which it calls.  The purpose is to give me the ability to pass in the query and execute the BatchActivityGrouping-batch all from another schedulable class that I have.

 

When I try to modify the classes I keep running into "Constructor Not Defined Errors" and am stuck.  Any thoughts on how to do this?  Thanks in advance.

 

CODE:

 

global class BatchActivityGrouping implements Database.Batchable<AggregateResult>

{

    

  global Iterable<AggregateResult> start(Database.BatchableContext info){

 

        return new AggregateResultIterable();

   }

  

   

  global void execute(Database.BatchableContext BC, List<Sobject> scope){

     List<Activity_Grouping__c> lstMoRecordsToProcess = new List<Activity_Grouping__c>();  

     for (Sobject so : scope)  {       

           //iterate through list 

      }        

   }

 

  

  global void finish(Database.BatchableContext BC)

  {

    //send completion email

  }

  

  global class AggregateResultIterable implements Iterable<AggregateResult> {

        global Iterator<AggregateResult> Iterator(){

            return new AggregateResultIterator();

       }             

   }

   

   global class AggregateResultIterator implements Iterator<AggregateResult> {

        AggregateResult [] results {get;set;}

        Integer index {get; set;} 

 

        global AggregateResultIterator() {

            index = 0;

            String query = 'SELECT a.Contact_Id__c, a.Completed_Date__c FROM Accumulated_Activity__c a '

            'WHERE a.Completed_Date__c = LAST_MONTH GROUP BY a.Completed_Date__c';

            results = Database.query(query);            

        } 

 

        global boolean hasNext(){ 

           return results != null && !results.isEmpty() && index < results.size(); 

        }    

 

        global AggregateResult next(){ 

            return results[index++];            

        }       

    }   

}

Greetings,

 

I am attempting something pretty simple.  I have a list of accounts displayed and I want to make the account name clickable so that it goes to the corresponding record.  I have the code implemented but when I click the account name, it goes to a page that says "ERROR URL NO LONGER EXISTS."  Your help is greatly appreciated.  My code is as follows:

 

***************************************VF Page******************************************************

 

<apex:page controller="NewController" >

<apex:form id="theForm">

<apex:pageBlock title="{!$User.FirstName}'s Accounts">

<apex:commandButton value="Save" action="{!save}" rerender="theForm,msg"/>
<apex:commandbutton value="Edit" action="{!edit}" rerender="theForm"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
<br></br><br></br><b>Note: Selecting "Recycle will auto-populate the DQ Reason ("No Longer Wish to Pursue").</b><p></p>

<apex:pageblocktable value="{!myaccounts}" var="acct">
<apex:column headervalue="Account">
<apex:outputlink value="/!{acct.id}">{!acct.Name}</apex:outputlink>
<apex:inputField value="{! acct.Name}" rendered="{!IsEditEnabled}"/>
</apex:column>


<apex:column headervalue="Recycle">
<apex:outputField value="{!acct.type}"/><br/>
<apex:inputfield value="{! acct.type}" rendered="{!IsEditEnabled}"/>
</apex:column>

<apex:column headervalue="DQ Reason">
<apex:outputField value="{!acct.DQ_Reason__c}" />
</apex:column>

</apex:pageblocktable>

<apex:pageMessages id="msg"/>
<p></p> <B> Note: Selecting "Recycle will auto-populate the DQ Reason ("No Longer Wish to Pursue").</B><br/><br/>
<apex:commandButton value="Save" action="{!save}" rerender="theForm,msg"/>
<apex:commandbutton value="Edit" action="{!edit}" rerender="theForm"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageblock>
</apex:form>
</apex:page>

 

 

***********************************************************Controller*********************************************************************

 

public class NewController {

public List<Account> myAccounts;
public Boolean isEditEnabled;

//Constructor called when page is accessed.
public NewController(){
myAccounts = new List<Account>();
isEditEnabled = false;
}

public List<Account> getMyAccounts(){
myAccounts = [select Id,name,type, dq_reason__c from Account WHERE type != 'Customer' and type != 'Disqualified' and (owner.id =: userinfo.getuserid()) order by name];
return myAccounts;
}

public PageReference edit() {
isEditEnabled = true;

return null;
}

public PageReference cancel() {
iseditenabled = false;
return null;
}

public PageReference save() {

for (account a: myaccounts){
if(a.type == 'Disqualified'){
apexpages.addmessage(new apexpages.message(ApexPages.severity.ERROR,'Invalid entry, "Disqualified" option not yet supported. Contact your administrator.'));

return null;
}
if(a.type == 'Recycle'){
a.dq_reason__c = 'No Longer Wish to Pursue';
}
else if(a.type != 'Recycle'){
a.dq_reason__c = '';
}

}
update myAccounts;
isEditEnabled = false;
return null;
}

public Boolean getIsEditEnabled(){
return isEditEnabled;
}
}

HI

 

I am calling a class from trigger and class has below statements.

 

PageReference pageref=new PageReference('https://test.abcd.xyz.force.com/abcd/apex/forcetest?id=xxxxxxxxxxxxxxx');
pageref.setRedirect(true);
Blob b=pageref.getContentAsPDF();

 

and I have another page with name 'forcetest'. I am passing id from this class to 'forcetest' visual force page later i do renderas PDF. But when im doing this i could generate a pdf but not able to get the id in 'forcetest' page  related controller.

 

Any Idea!

I'm having some issues getting the values in my var attribute when using apex:column and apex:outputText.

 

Say I have the following pageBlockTable:

<apex:pageBlockTable value="{!charges}" var="a" id="adjustment_charges">
  <apex:column headerValue="Amend Action" value="{!a.Local_Price__c}" />
  <apex:column headervalue="test">
    <apex:outputText >
       <apex:param value="{!a.Local_Price__c}"/>
     </apex:outputText>
                    
   </apex:column>
</apex:pageBlockTable>

 For me, the first column prints out the local price, while the second "test" column prints out blank

 

Any ideas what I am doing wrong?

I have a visualforce page that shows charts that I would like to filter based on a filter header  settings. For example, when the user selects a specific Country, the charts will be rerendered for just that country data.  Below is the controller for the filter page showing the dropdown values. Below that is the master page that includes the filter page, and other visualforce pages that display the charts, each with its own controller. How can I share the value of the dropdown selection wiht the controllers for the included pages?

 

Thanks!

 

public with Sharing class PracticeFilterClass{

 

// public List<SelectOption> Filter {get;set;}
 
public String SelectedFilter{get;set;}
public String SelectedRegion{get;set;}
public String SelectedCountry{get;set;}
public String SelectedStateProvince{get;set;}
public String SelectedCity{get;set;}
public String SelectedRole{get;set;}

 

etc...

 

VisualForcePage:

 

<apex:page >
<apex:include pageName="FilterHeaderPage"/>
<apex:include pageName="MyDashboardInfo"/>
<apex:include pageName="MyDashboardRow2"/>
</apex:page>

 

 

I am trying to navigate to account detial page when user clicks it.

When I try to hard code the account id from "https://na15.salesforce.com/addrInstances[i].id"  to a001ljsdklsd213.It is navigating to right account but it si not going to detail page when I use "https://na15.salesforce.com/addrInstances[i].id"

 

What I am doing wrong here..

 

 

google.maps.event.addListener(marker, 'click', function() {

window.location ='https://na15.salesforce.com/addrInstances[i].id';
alert(addresses[i].name);
});

 

I want to change owner of Custom Object Book according Lookup(Account)
Apex Class and  Triger are working fine in development mode, however stragling with Apex Test. It's comming with error complaining about invalid Id for Account__c which is lookup field on Book object to Account Object.
Tkank you for any advise how to move on.

Trigger

trigger BookDealerTrigger on Book__c (after insert, after update) {
    Book__c[] books = Trigger.new;
    BookDealer.changeOwner(books);
}

 



Apex Class

public class BookDealer {
 public static void changeOwner(Book__c[] books) {
   for (Book__c b :books){
   
       if(b.Account__c != ''){
           Account a = [SELECT Name FROM Account WHERE ID = :b.Account__c LIMIT 1];
     
          if(a.Name == 'Grand Hotels Resorts Ltd'){
              b.OwnerID = '00590000000YeiV'; //user1
          }elseif(a.Name == 'Something else'){
              b.OwnerID = '00590000000xxx'; //user2
          }//etc
       }
   }
}
}

 




Apex Test

@isTest
private class BookDealerTestClass {
   
    static testMethod void validateBookDealer(){
       
        Account a = new Account(Name='Grand Hotels Resorts Ltd');
        insert a;
       
        // Tell Salesforce that we are starting our test now
  test.startTest();
       
        Book__c b = new Book__c(Name='Behind the Cloud', Price__c=100, Account__c=a.Id);
        System.debug('Creating new book: ' + b.Price__c);
       
        //Insert book
        insert b;
       
        test.stopTest();
       
        /*
        if(b.Account__c== '00190000003NVJx'){
            b.OwnerID = '00590000000YeiV'; //User1
        }
       
        if(a.Name=='Grand Hotels & Resorts Ltd'){
       
            //Test that the trigger correctly updated the owner according account lookup
            System.assertEquals('00590000000YeiV', b.OwnerId);
          
       
        }
        */
       
       
    }
}

 

Apologies if this has already been answered but I have spent more than an hour looking and still cannot find an answer to my problem:

 

I am using a datepicker on an apex:inputtext field, to establish a from and to date range. It works fine, but when the screen is refreshed the value in the date changes from:

 

   D/MM/YYY format (what I am after), to something like this: 

   Mon Jul 15 00:00:00 GMT 2013

 

Therefore, next time I attempt to perform an action, I get an error message saying:

 

   Error:   Value 'Mon Jul 15 00:00:00 GMT 2013' cannot be converted from Text to Date
 
How can I prevent the date from being incorrectly reformatted?
 
Here is an exceprt from my VF code:
 

<apex:pageBlockSectionItem >
   <apex:outputLabel value="From Due Date" for="fromDate"/>
   <apex:inputText value="{!fromDateCriteria}" size="10" onfocus="DatePicker.pickDate(false, this, false);" id="fromDate" />
</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >

 

<apex:pageBlockSectionItem >
   <apex:outputLabel value="To Due Date" for="toDate"/>
   <apex:inputText value="{!toDateCriteria}" size="10" onfocus="DatePicker.pickDate(false, this, false);" id="toDate" />
</apex:pageBlockSectionItem>

 

 

My controller simply uses auto getters and setters:

 

public date FromDateCriteria {get;set;}
public date ToDateCriteria {get;set;}

 

Everything work fine, except for the reformat when the UI is redisplayed.

 

Thanks in advance...

Hello,

 

I am looking to have a quick, efficient way to automatically (or very simply) create tax-deductible donation thank you/receipt letters immediately after I enter a donation into Salesforce. Ideally, these would be pdfs that could be instantly emailed to the respective contact via the click of a button (or even better, automatically). 

 

A Salesforce rep directed me to this forum as a way to do it. Can anyone help me get it set up? 

 

P.S. I have already looked into CongaComposer and unfortunately >500$ a month is simply too expensive for our NFP organization.

Thanks!

 

Hi,

 

Scenario 1:

--------------------

I am using a Wrapper class to prepare a List<Wrapper> in ctrlr using action function.

 

When the action function gets invoked, I am able to prepare the List<Wrapper>.

 

I have declared the  List<Wrapper>. as Controller variable.

 

Scenario 2:

----------------

 

Upon another ui action(say on click of radio button), am invoking another action function.

 

In the controller,when I tried to access the List<Wrapper> prepared earlier, I am getting null.

 

The constructor doesnot get invoked between scenario1 and scenario 2.

 

Could any one please help me.

 

 

 

 

Hello,

 I Wanna write data to the CSV file, and i have the values of those variables in my controller.

 

How do i di it.

 

<apex:page controller="comm" cache="true" contentType="text/csv#File.csv" language="en-US">
</apex:page>

 I know the above method to create a file as File.csv.

But how do i write data to CSV.

 

Thanks.

I am trying to create a simple VF page that renders a PDF from HTML that is passed in by my controller. Using the VF code below, the dynamic HTML renders properly as a regular VF page, but when I add the "renderAs="PDF" to my page tag, only the raw HTML appears in the PDF and not the properly rendered HTML.

 

The following correctly renders the dynamic HTML:

<apex:page controller="trainingLetterPDFController" >
    <apex:outputText value="{!LetterHTMLBody}" escape="false"/>
</apex:page>

 The following renders the page as a PDF showing the raw HTML text:

<apex:page controller="trainingLetterPDFController" renderAs="PDF">
    <apex:outputText value="{!LetterHTMLBody}" escape="false"/>
</apex:page>

 

Any suggestions on how to get this dynamic HTML to render in the PDF?

Thanks!