• sonam
  • NEWBIE
  • -1 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 16
    Questions
  • 6
    Replies
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
 
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>)

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.

 

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;
}
}







}

 

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;
        }
        
       
}

 

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