• sonam
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 16
    Questions
  • 6
    Replies
Hi All,

There is a VF page that is rendered as pdf and it has the details that are present in a data table.
Currently we fetch the table header values via custom settings.

Users would like to have an option of changing resultset that is rendered without changing the code.

I tried VF components but we cant use fieldsets in them.

Thanks in advance.

Please suggest for an approach.
 
  • October 12, 2016
  • Like
  • 0
Hi,
I want to create a case via a rest Call and assign the owner as queue.
I tried assigning it from the code but it gets changed to the default owner of the org.
I even tried it using a workflow but the same is happening.
Please find the screenshot of the activity on case.
User-added image

Please assist.

Thanks in Advance,
Sonam
 
  • January 25, 2016
  • Like
  • 0
I am using the send an email functionality to send email to multiple users . It works fine. But, it creates just one activity , i.e. against the 'TO: ' recepient. I need to create activity for the 'ADDITIONAL TO:' . Please suggest a solution. Thanks .
  • June 19, 2014
  • Like
  • 1
There is an account having two record types say A and B . I am displaying the records based on record types on a VF page in two grids . There is a checkbox infront of every record . The records are being displayed but i want to check some records and on the basis of checked records i want to send an email to the checked records . How to retrive ids of checked records on the controller and send email to them ?????????
  • May 26, 2014
  • Like
  • 0
I am creating a dummy parent account and list of child accounts in my test class which are referring to the parent account . Test class is written on an account insert trigger operation . But whenever the list of child accounts is inserted , value of parent id is coming null and the feilds of parent are also not populated on child ... Can any one tell why parent id is coming null or how to assign a parent account id to child account .
Thanks in advance ... :)
  • April 18, 2014
  • Like
  • 0
Hi!

I need to define a javascript method on the event
like onChange='' some javascript code"  in the following code bt its giving an error: Unsupported attribute onchange in <apex:actionsupport>

             <apex:selectRadio value="{!Value}">
                    <apex:selectOptions value="{!items}"/>
                     <apex:actionsupport event="onchange" rerender="someBlock" status="waitStatus"  onChange='' some javascript code" />
                 </apex:selectRadio>

Thanks in advance.

  • January 13, 2014
  • Like
  • 0
Hi,

I have to implement a search functionality where

public class mycustomcontroller
{
public List<Contact> ContactObjects {get;set;}
 
public  PageReference runSearch(){
String firstName= ContactObj.FirstName;

// code
}
}

In the VF page i have used the below to capture the firstname.

<td><apex:outputLabel >Contact First Name &nbsp;</apex:outputLabel></td>
                    <td>
                 <apex:inputField value="{!ContactObj.FirstName}" id="fname"/>    
   </td>

M not able to get the value of firsntname.Its null in the debug logs.

Please help.

Thanks in advance.
  • January 09, 2014
  • Like
  • 0
I am trying to write a test class and i get the following error..
I do have a static flag in the trigger class chk the recursive calling of the future class

System.DmlException: Update failed. First exception on row 0 with id 500R0000004VgTGIA0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CaseTrigger_BeforeAfter_InsertUpdate: execution of AfterUpdate

caused by: System.AsyncException: Future method cannot be called from a future or batch method: CaseClass.method1(LIST<Id>)
  • January 02, 2014
  • Like
  • 0

Requirement:

1. On the save of CASE we want to open newly created Case Review in 'EDIT' mode.(Case is Parent Object and Case Review Detail Object)

2. Case review has certain fields populated from case.

3. We are using standard page layout.

 

Please help. we've reached a dead end.

 

 

  • December 10, 2013
  • Like
  • 0

I have to query from a custom object.

In the apex class i have to pass two lists as given below:

 

Select  field1__c,field2__c ,  ,field3__c,field4__c,field5__c,field6__c,field7__c
From Object_custom__c where
field1__c in : List1 AND 
field6__c in : List6

 

When I run the following query in developer console but it gives 'Unknown error parsing query'.

 

Select  field1__c,field2__c ,  ,field3__c,field4__c,field5__c,field6__c,field7__c
From Object_custom__c where
field1__c in : ['Field1_value1,' Field1_value2'] AND 
field6__c in : ['Field6_value1,' Field6_value2']

 

 

  • November 20, 2013
  • Like
  • 0

Hi!

Theres a requirement where the client wants:

1. Dependent Picklist 2 levels of dependency

2. An upload of file a/c to the picklist values

 

Problem (inputfile with rerender): the picklist rerenders the form when the value of the controlling picklist change.

 If i have two different forms,I 'm not able to capture the values of the picklist.


 

Please help me to find a way to merge these two in the same page. if possible without the use of 2 forms.

 

 

  • October 03, 2013
  • Like
  • 0

Hi,

 

I need to merge two codes.

The following code saves the document is salesforce folder.

The same doc needs to be pushed to a server by the method addFile().

/*** Controller ***/
public class documentExt { public documentExt(ApexPages.StandardController controller) { Document d = (Document) controller.getRecord(); d.folderid = UserInfo.getUserId(); //this puts it in My Personal Documents } }
public pagereference addFile()
    {
        String fSchema = Label.fileScheme;
        try{
                      Blob body=EncodingUtil.Base64Decode(data);
                      // calling method to push file to share folder
                       String path =  fileService.fileUploader(fileName,body,fSchema);
                      //system.debug('File Path-----'+path);
                      File__c f=new File__c();
                      f.Full_File_Name__c=fileName;
                      f.File_Path__c=path;
                      List<String> filenames=fileName.replace('.','#').split('#');
                      f.name=(filenames[0].length()>80)?(filenames[0].subString(0,79)):filenames[0];
                      f.Type__c=filenames[1];
                      String objectName=UtilityClass.findObjectNameById(parentId);
                      insert f;
                      data='';
                      fileName='';
                      parentId='';
                      contentType='';
                      msg='normal';
                      return null;
         }
         catch(Exception ex)
         {
              msg=ex.getMessage();
              data='';
              fileName='';
              return null;
         }
    }

 

  • October 01, 2013
  • Like
  • 0

Please help

 

1. Initially 5hours were added to the GMT.

   But , when i give a future date ...... i get the current date.

 

 

 

public static String printDate(Datetime Value,String format)
  {
  
		datetime systemDate = datetime.now();
		String timeZone = UserInfo.getTimeZone().getID();
		System.debug('getTimeZone-----------------'+timeZone);
		if(!systemDate.isSameDay(Value))
		{
			System.debug('not current date');
			Value = Value.addHours(5);
		}
		
		return Value.format(format);
  
  }

 

2. I tried to pass the timezone but I am unable to correct it.

    It gives me the previous date by the following code.

 

public static String printDate(Datetime Value,String format)
  {
  
	
	datetime systemDate = datetime.now();
	String timeZone = UserInfo.getTimeZone().getID();
	System.debug('getTimeZone-----------------'+timeZone);
	if(!systemDate.isSameDay(Value))
	{
		System.debug('date --------'+ Value);
		System.debug('not current date');
		System.debug('getTimeZone-----------------'+timeZone);
		System.debug('value is time zone>>>'+UserInfo.getTimeZone().getDisplayName());
		String ValueLocalDate = Value.format(format,timeZone);
		System.debug('ValueLocalDate-----------------'+ValueLocalDate);        

		return ValueLocalDate ;
	}
	
	return Value.format(format);
  }

I checked the debug logs to find that the timestamp is taken as 2013-01-05 00:00:00 and not the original time

Time is taken as 00:00:00

 

Thanks in advance.

 

  • September 11, 2013
  • Like
  • 0

Hi,

I'm quite new to salesforce.

I'm developing a mock page it should have the following fuctionality.

 

1. Search book and customer on basis of certain fields.(runs successfully)

2. Select the book and customer(which are selected through radio button) and sent in the click of 'ISSUE' button.

3. After clicking issue the book should be assigned and the borrower field of the book should be updated by the customer ID.

 

I'm able to do the 1st.

I get the values initially in debug but wen it comes to my 'Issue method' it flushes the values

I am not able to retrieve the values of radio button in the apex class.

 

Please guide me on this.

 

Below is my class and the VF page

<apex:page controller="newBookController">

<apex:form >
            <apex:sectionHeader title="Search a Customer"/>
                <apex:outputLabel style="font-weight:bold;" value="Name" ></apex:outputLabel>
                    <apex:inputText value="{!Name}"/> 
                    
            <br></br> 
        
            <apex:sectionHeader title="Search for a Book"/>
                <apex:outputLabel style="font-weight:bold;" value="Author" ></apex:outputLabel>
                    <apex:inputText value="{!Author}"/> 
                    
                <br></br> 
                <apex:outputLabel style="font-weight:bold;" value="Book Name" ></apex:outputLabel>
                    <apex:inputText value="{!BookName}"/>
                    
                <br></br> 
                <br></br>  
                        
                <apex:outputLabel style="font-weight:bold;" value="Price" >    
                    <apex:selectRadio id="selectRadio" value="{!bookPriceRange}">
                    <apex:selectOptions value="{!priceRange}"/>
                    </apex:selectRadio>
                </apex:outputLabel>
                    <apex:inputText value="{!price}"/>
    <br></br> 
    <br></br>   
    <br></br>
    
    
<apex:commandButton action="{!search}" value="Search" id="search" rerender="out, msgs, table" status="status"/>
    </apex:form>


<apex:form > 

<apex:outputpanel id="table">
        <apex:pageBlock >
                <apex:pageBlockTable value="{!Books}" var="c" >
                    <apex:column headerValue="select">
                        <apex:actionSupport action="{!getBook}" event="onclick" rendered="true" reRender="hidden">
                            <input type="radio" name="selectBook" id="id">
                            <apex:param name="BookID" value="{!c.Id}"/>
                            </input>
                        </apex:actionSupport>
                    </apex:column>
                    
                    <apex:column >
                            <apex:facet name="header">ID</apex:facet>
                            <apex:commandLink action="{!gotoPage}" id="theCommandLink" value="{!c.name}"> 
                            <apex:param value="{!c.id}" name="pid" ></apex:param>
                            
                            </apex:commandLink> 
                </apex:column>
                    
                    <apex:column >
                            <apex:facet name="header">Author</apex:facet>
                            <apex:outputField value="{!c.Author__c}" ></apex:outputField>
                    </apex:column>
                    <apex:column >
                            <apex:facet name="header">Book Name</apex:facet>
                            <apex:outputField value="{!c.Book_Name__c}" />
                    </apex:column>
                
                    <apex:column >
                            <apex:facet name="header">Price</apex:facet>
                            <apex:outputField value="{!c.price__c}" />
                    </apex:column>
                
                
                </apex:pageBlockTable>
        </apex:pageBlock>

    <apex:pageBlock >
            <apex:pageBlockTable value="{!Customers}" var="c">
                   
                    <apex:column headerValue="select">
                        <apex:actionSupport action="{!getCustomer}" event="onclick" rendered="true" reRender="hidden">

                            <input type="radio" name="selectCustomer" id="id">
                            <apex:param name="CustomerID" value="{!c.Id}"/>
                            </input>
                        </apex:actionSupport>
                    </apex:column>
                    <apex:column >
                        <apex:facet name="header">ID</apex:facet>
                        <apex:outputField value="{!c.Name}" />
                    </apex:column>
                    <apex:column >
                        <apex:facet name="header">Customer Name</apex:facet>
                        <apex:outputField value="{!c.Name__c}" />
                    </apex:column>
            
            </apex:pageBlockTable>
    </apex:pageBlock>


</apex:outputPanel>

<apex:commandButton action="{!issue}" value="Issue" id="Issue" rerender="out, msgs, table" status="status"/>

</apex:form>



</apex:page>

 

public class newBookController {

List <Book__c> Books;
List <Book__c> BooksSelected;
List <Customer__c> Customers;
private String Name=null;
private String Author= null;
private String BookName= null;
String bookPriceRange=null;
Double price=null;
integer flag=0;
public String selectBook =null;
public String selectcustomer=null;
public String selectBookIssue =null;
public String selectcustomerIssue=null;






    public String getAuthor() { return Author; }
    public void setAuthor(String dataAuthor) { Author = dataAuthor; }
    
    public String getName() { return Name; }
    public void setName(String dataName) { Name = dataName; }
    
    public String getBookName() { return Bookname; }
    public void setBookName(String dataBookname) { BookName= dataBookname; }
    
    public String getBookPriceRange() {  return bookPriceRange;    }
    public void setBookPriceRange(String bookPriceRange) { this.bookPriceRange= bookPriceRange; }
    
    public Double getPrice() {  return price;    }
    public void setPrice(Double price) { this.price= price; }




    
     public List<SelectOption> getPriceRange() {
        List<SelectOption> options = new List<SelectOption>(); 
        options.add(new SelectOption('Greaterthan','Greater than')); 
        options.add(new SelectOption('Lessthan','Less than')); 
        options.add(new SelectOption('Equalto','Equal to')); return options; 
    }
                   
   
    
public void search()
        {  


            If(Name!=null)
                    {
                        String queryStr = 'SELECT Name__c,Name from Customer__c WHERE'  + '(Name__c like \'%' + Name+ '%\')';
                        Customers=DataBase.query(queryStr);

                    }      
                    
 //-------------------- Code to search for book-------------------------------------// 
                          
            If(price==null  || bookPriceRange==null)           
 

                    {
                        
                        
                        If (Author!=null && (BookName=='' && BookName==null) )          
                            {
                                String queryStr = 'SELECT Author__c,Book_Name__c,Name from Book__c WHERE'  + '(Author__c like \'%' + Author+ '%\')';
                                Books=DataBase.query(queryStr);
                                
                                system.debug('Books-----------------with like AUTHOR-------------  -------------'+Books);
                            }

                        If ((Author==null && Author=='')&& BookName !=null )           
                            {
                                String queryStr = 'SELECT Author__c,Book_Name__c,Name from Book__c WHERE'  + '(Book_Name__c  like \'%' + Bookname + '%\')';
                                Books=DataBase.query(queryStr);
                                system.debug('Books-----------------with like BOOK NAME-------------  -------------'+Books);
                            }




                        If (Author!=null && BookName!=null )          
                            {
                            
                                String queryStr = 'SELECT Author__c,Book_Name__c,Name from Book__c WHERE'  + '(Author__c like \'%' + Author+ '%\')' + 'or'+ '(Book_Name__c  like \'%' + Bookname + '%\')';
                                Books=DataBase.query(queryStr);
                                system.debug('Books-----------------with like BOOK NAME-------------  -------------'+Books);
                            }
                }

        else

        {


                If(bookPriceRange=='Equalto' )
                    {
                    
                                If (Author!=null && (BookName=='' && BookName==null))           
                                {
                                            String queryStr = 'SELECT Author__c,Book_Name__c,Name,price__c from Book__c WHERE'  
                                            + '(Author__c like \'%' + Author+ '%\')'
                                            +'and'
                                            +'(price__c = :price)'
                                            ;
                                            Books=DataBase.query(queryStr);
                                            
                                            system.debug('Books-----------------with like AUTHOR-------------  -------------'+Books);
                                }

                                If ((Author==null && Author=='')&& BookName !=null)           
                                {
                                            String queryStr = 'SELECT Author__c,Book_Name__c,Name,price__c from Book__c WHERE '  
                                            + '(Book_Name__c  like \'%' + Bookname + '%\')'
                                            +'and'
                                            +'(price__c = :price)';
                                            Books=DataBase.query(queryStr);
                                            system.debug('Books-----------------with like BOOK NAME-------------  -------------'+Books);
                                }
                                



                                If (Author!=null && BookName!=null   )           
                                {
                                
                                            String queryStr = 'SELECT Author__c,Book_Name__c,Name,price__c from Book__c WHERE'  
                                            +'('+ 
                                            
                                            +'('+ 
                                            + '(Author__c like \'%' + Author+ '%\')' 
                                            + 'or'
                                            + '(Book_Name__c  like \'%' + Bookname + '%\')'
                                            +')'+
                                            +'and'
                                            +'(price__c =  :price))';
                                            Books=DataBase.query(queryStr);
                                            system.debug('Books-----------------with like BOOK NAME-------------  -------------'+Books);
                                }
                                

            }
 
            {
        If(bookPriceRange=='Greaterthan' )
            {


                If (Author!=null && (BookName=='' && BookName==null))           
                {
                        String queryStr = 'SELECT Author__c,Book_Name__c,Name,price__c from Book__c WHERE'  
                        + '(Author__c like \'%' + Author+ '%\')'
                        +'and'
                        +'(price__c > :price)'
                        ;
                        Books=DataBase.query(queryStr);
                        
                        system.debug('Books-----------------with like AUTHOR-------------  -------------'+Books);
                }

                If ((Author==null && Author=='')&& BookName !=null)           
                {
                        String queryStr = 'SELECT Author__c,Book_Name__c,Name,price__c from Book__c WHERE '  
                        + '(Book_Name__c  like \'%' + Bookname + '%\')'
                        +'and'
                        +'(price__c > :price)';
                        Books=DataBase.query(queryStr);
                        system.debug('Books-----------------with like BOOK NAME-------------  -------------'+Books);
                }




                If (Author!=null && BookName!=null   )           
                {
                
                        String queryStr = 'SELECT Author__c,Book_Name__c,Name,price__c from Book__c WHERE'  
                        +'('+ 
                        
                        +'('+ 
                        + '(Author__c like \'%' + Author+ '%\')' 
                        + 'or'
                        + '(Book_Name__c  like \'%' + Bookname + '%\')'
                        +')'+
                        +'and'
                        +'(price__c >  :price))';
                        Books=DataBase.query(queryStr);
                        system.debug('Books-----------------with like BOOK NAME-------------  -------------'+Books);
                }


}


{
    If(bookPriceRange=='Lessthan' )
    {



                If (Author!=null && (BookName=='' && BookName==null))           
                {
                        String queryStr = 'SELECT Author__c,Book_Name__c,Name,price__c from Book__c WHERE'  
                        + '(Author__c like \'%' + Author+ '%\')'
                        +'and'
                        +'(price__c < :price)'
                        ;
                        Books=DataBase.query(queryStr);
                        
                        system.debug('Books-----------------with like AUTHOR-------------  -------------'+Books);
                }

                If ((Author==null && Author=='')&& BookName !=null)           
                {
                        String queryStr = 'SELECT Author__c,Book_Name__c,Name,price__c from Book__c WHERE '  
                        + '(Book_Name__c  like \'%' + Bookname + '%\')'
                        +'and'
                        +'(price__c < :price)';
                        Books=DataBase.query(queryStr);
                        system.debug('Books-----------------with like BOOK NAME-------------  -------------'+Books);
                        }




            If (Author!=null && BookName!=null   )           
            {
            
                        String queryStr = 'SELECT Author__c,Book_Name__c,Name,price__c from Book__c WHERE'  
                        +'('+ 
                        
                        +'('+ 
                        + '(Author__c like \'%' + Author+ '%\')' 
                        + 'or'
                        + '(Book_Name__c  like \'%' + Bookname + '%\')'
                        +')'+
                        +'and'
                        +'(price__c <  :price))';
                        Books=DataBase.query(queryStr);
                        system.debug('Books-----------------with like BOOK NAME-------------  -------------'+Books);
            }


}


}          


}

}         




//-------------------code to search for customers--------------------




}    
public List<Customer__c> getCustomers() {

return Customers;
}

public List<Book__c> getBooks() {

return Books;
}


public PageReference gotoPage() 
{
system.debug('in gotoPage method');
String idVal = ApexPages.currentPage().getParameters().get('pid');
system.debug('idVal>>>'+idVal);
PageReference redirect = new PageReference('https://ap1.salesforce.com/'+idVal); 
//redirect.getParameters().put('id',ApexPages.currentPage().getParameters().get('id')); 

redirect.setRedirect(true); 

return redirect;
}

public void getCustomer()
{
//--------------- getting the value in debug

selectcustomer = System.currentPagereference().getParameters().get('CustomerID');
system.debug('------------------------customer--------------'+selectcustomer);
String selectcustomerIssue=selectcustomer;

}

public void getBook()
{
//--------------- getting the value in debug
selectBook = ApexPages.currentPage().getParameters().get('BookID');
system.debug('-------------------------book---------------'+selectBook);
String selectBookIssue=selectBook;

}
 
public void issue()
{
//---------------------debug value= null----------------------
system.debug('------------------------customer-issue-------------'+selectcustomerIssue);

system.debug('-------------------------book----issue-----------'+selectBookIssue);



//String queryBook ='(Select id,price__c,Name,Name__c from Book__c where borrower__c=:selectcustomer)';
//BooksSelected=DataBase.query(queryBook);


//        for(Book__c b:BooksSelected)
  //          {
    //            if(b.id==selectBook)
      //              {
        //            flag=1;
          //          }
            //}
            
            
//If(flag==0)
  //  {
  //      Book__c BooksSelected = [SELECT Author__c,Book_Name__c,Name,price__c,borrower__c FROM Book__c WHERE id=:selectBook];
  //      BooksSelected.borrower__c =selectcustomer; 
    //    
      //  try 
          //  {
        //        update BooksSelected;
       //     } 
        //catch (DmlException e) 
       //     {
         //       system.debug('update done');
           // }
    
    //}




}



public void calTotalAmt(Book__c[] books)
{
for(Book__c b:BooksSelected)
{
price=price+b.price__c;
}
}







}

 

  • July 26, 2013
  • Like
  • 0

Accounts is a custom object.i have to retrieve the  account type on the basis of Name.
I am able to retrieve the id and i'm  getting  account type in debug. But, it isnt displayed in the VF page.
Please have a look at the code..

 

Given below is the code of Class and VF page

<apex:page controller="SearchByName">
 <apex:form >
  <apex:outputLabel style="font-weight:bold;" value="Search By Name" ></apex:outputLabel>
        <apex:inputText value="{!textData}"/> 
<apex:commandButton action="{!search}" value="Search" id="search" rerender="out, msgs" status="status"/>
 </apex:form>
 <!------Doesnt print the first name and account type------->
  <apex:pageBlock >
  <apex:pageBlockTable value="{!Accounts}" var="c" >
  <apex:column >
                <apex:facet name="header">First Name</apex:facet>
                <apex:outputField value="{!c.First_Name__c}" />
  </apex:column>
  <apex:column >
                <apex:facet name="header">Account Type</apex:facet>
                <apex:outputField value="{!c.Account_Type__c}" />
  </apex:column>

     
  </apex:pageBlockTable>
  </apex:pageBlock>
  
     <!------------- Getting the value of var "c"------------>
   <apex:outputPanel id="out">
        <apex:actionstatus id="status" startText="searching...">
            <apex:facet name="stop">
                <apex:outputPanel >
                    
                    <apex:dataList value="{!Accounts}" var="c">a:{!c}</apex:dataList>
                    
                </apex:outputPanel>
            </apex:facet>
        </apex:actionstatus>
    </apex:outputPanel>
 </apex:page>

 

public class SearchByName
{
 List<Account__c> Accounts;
private String textdata = null;

    public String getTextData() { return textdata; }
    
    public void setTextData(String data) { textdata = data; }
    
        
        
        public void search(){            
           
            Accounts = Database.query('SELECT First_Name__c,Account_Type__c  FROM Account__c where First_Name__c = :textdata');
            system.debug('Accounts>>>>'+Accounts);
       }    
        public List<Account__c> getAccounts() {
                
                return Accounts;
        }
        
       
}

 

  • June 28, 2013
  • Like
  • 0
I am using the send an email functionality to send email to multiple users . It works fine. But, it creates just one activity , i.e. against the 'TO: ' recepient. I need to create activity for the 'ADDITIONAL TO:' . Please suggest a solution. Thanks .
  • June 19, 2014
  • Like
  • 1
Hi,
I want to create a case via a rest Call and assign the owner as queue.
I tried assigning it from the code but it gets changed to the default owner of the org.
I even tried it using a workflow but the same is happening.
Please find the screenshot of the activity on case.
User-added image

Please assist.

Thanks in Advance,
Sonam
 
  • January 25, 2016
  • Like
  • 0
I am trying to write a test class and i get the following error..
I do have a static flag in the trigger class chk the recursive calling of the future class

System.DmlException: Update failed. First exception on row 0 with id 500R0000004VgTGIA0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CaseTrigger_BeforeAfter_InsertUpdate: execution of AfterUpdate

caused by: System.AsyncException: Future method cannot be called from a future or batch method: CaseClass.method1(LIST<Id>)
  • January 02, 2014
  • Like
  • 0

Please help

 

1. Initially 5hours were added to the GMT.

   But , when i give a future date ...... i get the current date.

 

 

 

public static String printDate(Datetime Value,String format)
  {
  
		datetime systemDate = datetime.now();
		String timeZone = UserInfo.getTimeZone().getID();
		System.debug('getTimeZone-----------------'+timeZone);
		if(!systemDate.isSameDay(Value))
		{
			System.debug('not current date');
			Value = Value.addHours(5);
		}
		
		return Value.format(format);
  
  }

 

2. I tried to pass the timezone but I am unable to correct it.

    It gives me the previous date by the following code.

 

public static String printDate(Datetime Value,String format)
  {
  
	
	datetime systemDate = datetime.now();
	String timeZone = UserInfo.getTimeZone().getID();
	System.debug('getTimeZone-----------------'+timeZone);
	if(!systemDate.isSameDay(Value))
	{
		System.debug('date --------'+ Value);
		System.debug('not current date');
		System.debug('getTimeZone-----------------'+timeZone);
		System.debug('value is time zone>>>'+UserInfo.getTimeZone().getDisplayName());
		String ValueLocalDate = Value.format(format,timeZone);
		System.debug('ValueLocalDate-----------------'+ValueLocalDate);        

		return ValueLocalDate ;
	}
	
	return Value.format(format);
  }

I checked the debug logs to find that the timestamp is taken as 2013-01-05 00:00:00 and not the original time

Time is taken as 00:00:00

 

Thanks in advance.

 

  • September 11, 2013
  • Like
  • 0

Hi,

I'm quite new to salesforce.

I'm developing a mock page it should have the following fuctionality.

 

1. Search book and customer on basis of certain fields.(runs successfully)

2. Select the book and customer(which are selected through radio button) and sent in the click of 'ISSUE' button.

3. After clicking issue the book should be assigned and the borrower field of the book should be updated by the customer ID.

 

I'm able to do the 1st.

I get the values initially in debug but wen it comes to my 'Issue method' it flushes the values

I am not able to retrieve the values of radio button in the apex class.

 

Please guide me on this.

 

Below is my class and the VF page

<apex:page controller="newBookController">

<apex:form >
            <apex:sectionHeader title="Search a Customer"/>
                <apex:outputLabel style="font-weight:bold;" value="Name" ></apex:outputLabel>
                    <apex:inputText value="{!Name}"/> 
                    
            <br></br> 
        
            <apex:sectionHeader title="Search for a Book"/>
                <apex:outputLabel style="font-weight:bold;" value="Author" ></apex:outputLabel>
                    <apex:inputText value="{!Author}"/> 
                    
                <br></br> 
                <apex:outputLabel style="font-weight:bold;" value="Book Name" ></apex:outputLabel>
                    <apex:inputText value="{!BookName}"/>
                    
                <br></br> 
                <br></br>  
                        
                <apex:outputLabel style="font-weight:bold;" value="Price" >    
                    <apex:selectRadio id="selectRadio" value="{!bookPriceRange}">
                    <apex:selectOptions value="{!priceRange}"/>
                    </apex:selectRadio>
                </apex:outputLabel>
                    <apex:inputText value="{!price}"/>
    <br></br> 
    <br></br>   
    <br></br>
    
    
<apex:commandButton action="{!search}" value="Search" id="search" rerender="out, msgs, table" status="status"/>
    </apex:form>


<apex:form > 

<apex:outputpanel id="table">
        <apex:pageBlock >
                <apex:pageBlockTable value="{!Books}" var="c" >
                    <apex:column headerValue="select">
                        <apex:actionSupport action="{!getBook}" event="onclick" rendered="true" reRender="hidden">
                            <input type="radio" name="selectBook" id="id">
                            <apex:param name="BookID" value="{!c.Id}"/>
                            </input>
                        </apex:actionSupport>
                    </apex:column>
                    
                    <apex:column >
                            <apex:facet name="header">ID</apex:facet>
                            <apex:commandLink action="{!gotoPage}" id="theCommandLink" value="{!c.name}"> 
                            <apex:param value="{!c.id}" name="pid" ></apex:param>
                            
                            </apex:commandLink> 
                </apex:column>
                    
                    <apex:column >
                            <apex:facet name="header">Author</apex:facet>
                            <apex:outputField value="{!c.Author__c}" ></apex:outputField>
                    </apex:column>
                    <apex:column >
                            <apex:facet name="header">Book Name</apex:facet>
                            <apex:outputField value="{!c.Book_Name__c}" />
                    </apex:column>
                
                    <apex:column >
                            <apex:facet name="header">Price</apex:facet>
                            <apex:outputField value="{!c.price__c}" />
                    </apex:column>
                
                
                </apex:pageBlockTable>
        </apex:pageBlock>

    <apex:pageBlock >
            <apex:pageBlockTable value="{!Customers}" var="c">
                   
                    <apex:column headerValue="select">
                        <apex:actionSupport action="{!getCustomer}" event="onclick" rendered="true" reRender="hidden">

                            <input type="radio" name="selectCustomer" id="id">
                            <apex:param name="CustomerID" value="{!c.Id}"/>
                            </input>
                        </apex:actionSupport>
                    </apex:column>
                    <apex:column >
                        <apex:facet name="header">ID</apex:facet>
                        <apex:outputField value="{!c.Name}" />
                    </apex:column>
                    <apex:column >
                        <apex:facet name="header">Customer Name</apex:facet>
                        <apex:outputField value="{!c.Name__c}" />
                    </apex:column>
            
            </apex:pageBlockTable>
    </apex:pageBlock>


</apex:outputPanel>

<apex:commandButton action="{!issue}" value="Issue" id="Issue" rerender="out, msgs, table" status="status"/>

</apex:form>



</apex:page>

 

public class newBookController {

List <Book__c> Books;
List <Book__c> BooksSelected;
List <Customer__c> Customers;
private String Name=null;
private String Author= null;
private String BookName= null;
String bookPriceRange=null;
Double price=null;
integer flag=0;
public String selectBook =null;
public String selectcustomer=null;
public String selectBookIssue =null;
public String selectcustomerIssue=null;






    public String getAuthor() { return Author; }
    public void setAuthor(String dataAuthor) { Author = dataAuthor; }
    
    public String getName() { return Name; }
    public void setName(String dataName) { Name = dataName; }
    
    public String getBookName() { return Bookname; }
    public void setBookName(String dataBookname) { BookName= dataBookname; }
    
    public String getBookPriceRange() {  return bookPriceRange;    }
    public void setBookPriceRange(String bookPriceRange) { this.bookPriceRange= bookPriceRange; }
    
    public Double getPrice() {  return price;    }
    public void setPrice(Double price) { this.price= price; }




    
     public List<SelectOption> getPriceRange() {
        List<SelectOption> options = new List<SelectOption>(); 
        options.add(new SelectOption('Greaterthan','Greater than')); 
        options.add(new SelectOption('Lessthan','Less than')); 
        options.add(new SelectOption('Equalto','Equal to')); return options; 
    }
                   
   
    
public void search()
        {  


            If(Name!=null)
                    {
                        String queryStr = 'SELECT Name__c,Name from Customer__c WHERE'  + '(Name__c like \'%' + Name+ '%\')';
                        Customers=DataBase.query(queryStr);

                    }      
                    
 //-------------------- Code to search for book-------------------------------------// 
                          
            If(price==null  || bookPriceRange==null)           
 

                    {
                        
                        
                        If (Author!=null && (BookName=='' && BookName==null) )          
                            {
                                String queryStr = 'SELECT Author__c,Book_Name__c,Name from Book__c WHERE'  + '(Author__c like \'%' + Author+ '%\')';
                                Books=DataBase.query(queryStr);
                                
                                system.debug('Books-----------------with like AUTHOR-------------  -------------'+Books);
                            }

                        If ((Author==null && Author=='')&& BookName !=null )           
                            {
                                String queryStr = 'SELECT Author__c,Book_Name__c,Name from Book__c WHERE'  + '(Book_Name__c  like \'%' + Bookname + '%\')';
                                Books=DataBase.query(queryStr);
                                system.debug('Books-----------------with like BOOK NAME-------------  -------------'+Books);
                            }




                        If (Author!=null && BookName!=null )          
                            {
                            
                                String queryStr = 'SELECT Author__c,Book_Name__c,Name from Book__c WHERE'  + '(Author__c like \'%' + Author+ '%\')' + 'or'+ '(Book_Name__c  like \'%' + Bookname + '%\')';
                                Books=DataBase.query(queryStr);
                                system.debug('Books-----------------with like BOOK NAME-------------  -------------'+Books);
                            }
                }

        else

        {


                If(bookPriceRange=='Equalto' )
                    {
                    
                                If (Author!=null && (BookName=='' && BookName==null))           
                                {
                                            String queryStr = 'SELECT Author__c,Book_Name__c,Name,price__c from Book__c WHERE'  
                                            + '(Author__c like \'%' + Author+ '%\')'
                                            +'and'
                                            +'(price__c = :price)'
                                            ;
                                            Books=DataBase.query(queryStr);
                                            
                                            system.debug('Books-----------------with like AUTHOR-------------  -------------'+Books);
                                }

                                If ((Author==null && Author=='')&& BookName !=null)           
                                {
                                            String queryStr = 'SELECT Author__c,Book_Name__c,Name,price__c from Book__c WHERE '  
                                            + '(Book_Name__c  like \'%' + Bookname + '%\')'
                                            +'and'
                                            +'(price__c = :price)';
                                            Books=DataBase.query(queryStr);
                                            system.debug('Books-----------------with like BOOK NAME-------------  -------------'+Books);
                                }
                                



                                If (Author!=null && BookName!=null   )           
                                {
                                
                                            String queryStr = 'SELECT Author__c,Book_Name__c,Name,price__c from Book__c WHERE'  
                                            +'('+ 
                                            
                                            +'('+ 
                                            + '(Author__c like \'%' + Author+ '%\')' 
                                            + 'or'
                                            + '(Book_Name__c  like \'%' + Bookname + '%\')'
                                            +')'+
                                            +'and'
                                            +'(price__c =  :price))';
                                            Books=DataBase.query(queryStr);
                                            system.debug('Books-----------------with like BOOK NAME-------------  -------------'+Books);
                                }
                                

            }
 
            {
        If(bookPriceRange=='Greaterthan' )
            {


                If (Author!=null && (BookName=='' && BookName==null))           
                {
                        String queryStr = 'SELECT Author__c,Book_Name__c,Name,price__c from Book__c WHERE'  
                        + '(Author__c like \'%' + Author+ '%\')'
                        +'and'
                        +'(price__c > :price)'
                        ;
                        Books=DataBase.query(queryStr);
                        
                        system.debug('Books-----------------with like AUTHOR-------------  -------------'+Books);
                }

                If ((Author==null && Author=='')&& BookName !=null)           
                {
                        String queryStr = 'SELECT Author__c,Book_Name__c,Name,price__c from Book__c WHERE '  
                        + '(Book_Name__c  like \'%' + Bookname + '%\')'
                        +'and'
                        +'(price__c > :price)';
                        Books=DataBase.query(queryStr);
                        system.debug('Books-----------------with like BOOK NAME-------------  -------------'+Books);
                }




                If (Author!=null && BookName!=null   )           
                {
                
                        String queryStr = 'SELECT Author__c,Book_Name__c,Name,price__c from Book__c WHERE'  
                        +'('+ 
                        
                        +'('+ 
                        + '(Author__c like \'%' + Author+ '%\')' 
                        + 'or'
                        + '(Book_Name__c  like \'%' + Bookname + '%\')'
                        +')'+
                        +'and'
                        +'(price__c >  :price))';
                        Books=DataBase.query(queryStr);
                        system.debug('Books-----------------with like BOOK NAME-------------  -------------'+Books);
                }


}


{
    If(bookPriceRange=='Lessthan' )
    {



                If (Author!=null && (BookName=='' && BookName==null))           
                {
                        String queryStr = 'SELECT Author__c,Book_Name__c,Name,price__c from Book__c WHERE'  
                        + '(Author__c like \'%' + Author+ '%\')'
                        +'and'
                        +'(price__c < :price)'
                        ;
                        Books=DataBase.query(queryStr);
                        
                        system.debug('Books-----------------with like AUTHOR-------------  -------------'+Books);
                }

                If ((Author==null && Author=='')&& BookName !=null)           
                {
                        String queryStr = 'SELECT Author__c,Book_Name__c,Name,price__c from Book__c WHERE '  
                        + '(Book_Name__c  like \'%' + Bookname + '%\')'
                        +'and'
                        +'(price__c < :price)';
                        Books=DataBase.query(queryStr);
                        system.debug('Books-----------------with like BOOK NAME-------------  -------------'+Books);
                        }




            If (Author!=null && BookName!=null   )           
            {
            
                        String queryStr = 'SELECT Author__c,Book_Name__c,Name,price__c from Book__c WHERE'  
                        +'('+ 
                        
                        +'('+ 
                        + '(Author__c like \'%' + Author+ '%\')' 
                        + 'or'
                        + '(Book_Name__c  like \'%' + Bookname + '%\')'
                        +')'+
                        +'and'
                        +'(price__c <  :price))';
                        Books=DataBase.query(queryStr);
                        system.debug('Books-----------------with like BOOK NAME-------------  -------------'+Books);
            }


}


}          


}

}         




//-------------------code to search for customers--------------------




}    
public List<Customer__c> getCustomers() {

return Customers;
}

public List<Book__c> getBooks() {

return Books;
}


public PageReference gotoPage() 
{
system.debug('in gotoPage method');
String idVal = ApexPages.currentPage().getParameters().get('pid');
system.debug('idVal>>>'+idVal);
PageReference redirect = new PageReference('https://ap1.salesforce.com/'+idVal); 
//redirect.getParameters().put('id',ApexPages.currentPage().getParameters().get('id')); 

redirect.setRedirect(true); 

return redirect;
}

public void getCustomer()
{
//--------------- getting the value in debug

selectcustomer = System.currentPagereference().getParameters().get('CustomerID');
system.debug('------------------------customer--------------'+selectcustomer);
String selectcustomerIssue=selectcustomer;

}

public void getBook()
{
//--------------- getting the value in debug
selectBook = ApexPages.currentPage().getParameters().get('BookID');
system.debug('-------------------------book---------------'+selectBook);
String selectBookIssue=selectBook;

}
 
public void issue()
{
//---------------------debug value= null----------------------
system.debug('------------------------customer-issue-------------'+selectcustomerIssue);

system.debug('-------------------------book----issue-----------'+selectBookIssue);



//String queryBook ='(Select id,price__c,Name,Name__c from Book__c where borrower__c=:selectcustomer)';
//BooksSelected=DataBase.query(queryBook);


//        for(Book__c b:BooksSelected)
  //          {
    //            if(b.id==selectBook)
      //              {
        //            flag=1;
          //          }
            //}
            
            
//If(flag==0)
  //  {
  //      Book__c BooksSelected = [SELECT Author__c,Book_Name__c,Name,price__c,borrower__c FROM Book__c WHERE id=:selectBook];
  //      BooksSelected.borrower__c =selectcustomer; 
    //    
      //  try 
          //  {
        //        update BooksSelected;
       //     } 
        //catch (DmlException e) 
       //     {
         //       system.debug('update done');
           // }
    
    //}




}



public void calTotalAmt(Book__c[] books)
{
for(Book__c b:BooksSelected)
{
price=price+b.price__c;
}
}







}

 

  • July 26, 2013
  • Like
  • 0

Accounts is a custom object.i have to retrieve the  account type on the basis of Name.
I am able to retrieve the id and i'm  getting  account type in debug. But, it isnt displayed in the VF page.
Please have a look at the code..

 

Given below is the code of Class and VF page

<apex:page controller="SearchByName">
 <apex:form >
  <apex:outputLabel style="font-weight:bold;" value="Search By Name" ></apex:outputLabel>
        <apex:inputText value="{!textData}"/> 
<apex:commandButton action="{!search}" value="Search" id="search" rerender="out, msgs" status="status"/>
 </apex:form>
 <!------Doesnt print the first name and account type------->
  <apex:pageBlock >
  <apex:pageBlockTable value="{!Accounts}" var="c" >
  <apex:column >
                <apex:facet name="header">First Name</apex:facet>
                <apex:outputField value="{!c.First_Name__c}" />
  </apex:column>
  <apex:column >
                <apex:facet name="header">Account Type</apex:facet>
                <apex:outputField value="{!c.Account_Type__c}" />
  </apex:column>

     
  </apex:pageBlockTable>
  </apex:pageBlock>
  
     <!------------- Getting the value of var "c"------------>
   <apex:outputPanel id="out">
        <apex:actionstatus id="status" startText="searching...">
            <apex:facet name="stop">
                <apex:outputPanel >
                    
                    <apex:dataList value="{!Accounts}" var="c">a:{!c}</apex:dataList>
                    
                </apex:outputPanel>
            </apex:facet>
        </apex:actionstatus>
    </apex:outputPanel>
 </apex:page>

 

public class SearchByName
{
 List<Account__c> Accounts;
private String textdata = null;

    public String getTextData() { return textdata; }
    
    public void setTextData(String data) { textdata = data; }
    
        
        
        public void search(){            
           
            Accounts = Database.query('SELECT First_Name__c,Account_Type__c  FROM Account__c where First_Name__c = :textdata');
            system.debug('Accounts>>>>'+Accounts);
       }    
        public List<Account__c> getAccounts() {
                
                return Accounts;
        }
        
       
}

 

  • June 28, 2013
  • Like
  • 0

Hi All,

 

I just finished the official training course given by Salesforce for our company.

They have also given us "DEV 401/501" student/exercise guide.

I would like to take the exam roughly a month from now.

 

Is the following reading materials enough for passing this exam ?

 

a) DEV 401 Guide (Student / Exercise)

 

b) Kindle version of "Development with the Force.com Platform: Building Business Applications in the Cloud" by Jason Ouellete

 

c) Force.com Fundamentas pdf

 

Also it would be nice to know if there are any particular key topics that I should focus on..

 

Thanks for your time :)

 

GVPY

  • February 27, 2012
  • Like
  • 0