• Buss
  • NEWBIE
  • 100 Points
  • Member since 2010

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 14
    Questions
  • 19
    Replies

Hi,

 

i have an custom object INDIVIDUAL CUSTOMER:-

In this object i have a picklist field Customer Type: 1> mechanic 2> Reborer 3> Retailer.

Now based on this Customer type there should be a unique field having the unique id say contact id.

 

For Eg:-  If the customer type is MECHANIC then the unique id field should be like {MEC-0000}

                 If the customer type is REBRER then the unique id field should be like {REB-0000}

                  If the customer type is RETAILER then the unique id field should be like {RET-0000}

 

Also, for each next Record created for mechanic it should be MEC-0000 then MEC-0001,MEC-0002 in the uniqueid field(contact id).

Simmilarly, 

                     for each next Record created for Rebrorer it should be REB-0000 then REB-0001,REB-0002 in the uniqueid field(contact id).

                     for each next Record created for RETAILER it should be RET-0000 then RET-0001,RET-0002 in the uniqueid field(contact id).


 

Can Anybody tell me how i can override standard button of every object with same Visualforce page?

i want same vf page for every object edit layout..

 

help..

Hi Everyone

I want to add more product in a perticular Quote.I know the relationship between Quote,QuoteLineItem ,Pricebook2,Product2 and PricebookEntry.my first product is saved but when I am  trying to add more product under a perticular Quote an error is fired.

"Id is not specified in an update call.."  .I have written update statement to update Quote because there is a required field Pricebook2Id in Quote.when I  am creating a new product at that time assisgning a unit price through PricebookEntry.Because Product2 and Pricebook2 are related in a many to many relationship and the junction object is PricebookEntry.

My problem is that how can we update PricebookId field In Quote each time when a Product is created.

That means there is one record in Quote but I have to created more product inside perticular Quote.

 

I am beginner in salesforce.May be I canot express my problem.So I request please help me in a simpler way....

Here is my code.

 

<apex:page controller= pcontactdetailcontroller>

................

...............

 

       <!----QUOTE table-->
  <apex:pageBlockSection title="Quote Details of a Perctcular Opportunity" rendered="{!table=='Show'}">
           
                <B>OPPORTUNITY NAME:&nbsp;{!Opportunity1.Name}</B>
            <!--<apex:outputField label="OPPORTUNITY" value="{!OpportunityContactRoles.Opportunity.Name}"/>-->
              <apex:outputPanel style="float:middle">
                  <p><B> All Quotes </B></P>
                 <apex:dataTable value="{!Opportunity1.Quotes}" var="Qut" cellpadding="2" border="1"  rowClasses="odd,even" >
           
                    <apex:column headerValue="Quote Name">
                    <apex:commandLink value="{!Qut.Name}"  title="to see product" style="font-size:15;color:blue;" action="{!forProduct}">
                     <apex:param name="quoteId" value="{!Qut.Id}"/>
                     </apex:commandLink>
                    </apex:column>
                     <apex:column headerValue="Status">{!Qut.Status}</apex:column>
               
                   </apex:dataTable>
                  </apex:outputPanel>
                  <apex:commandButton value="Add Quote" action="{!toaddQoute}"/>
             </apex:pageBlockSection>

 

 <!--product table------>
                 <apex:pageBlockSection title="Product Details" rendered="{!asish=='Show'}">
            
                  <B>OPPORTUNITY NAME:&nbsp;{!Opportunity1.Name}</B><br/><br/>
                  <B>QUOTE NAME:&nbsp;{!Quote1.Name}</B>
               <apex:outputPanel style="float:middle">
                  <p><B> Product Details </B></P>
                  <apex:datatable value="{!quote1.QuoteLineItems}" var="pdct" cellpadding="2" border="1"  rowClasses="odd,even">
                  <apex:column headerValue="Product Name">{!pdct.PricebookEntry.Product2.Name}</apex:column>
                  <apex:column headerValue="Unit Price">{!pdct.UnitPrice}</apex:column>
                  <apex:column headerValue="Quantity">{!pdct.Quantity}</apex:column>
                  <apex:column headerValue="Sub Total">"{!pdct.Subtotal}</apex:column>
                  <apex:column headerValue="Discount">"{!pdct.Discount}</apex:column>
                  <apex:column headerValue="TotalPrice">{!pdct.TotalPrice}</apex:column>
                  
                  </apex:datatable>
                  
               </apex:outputPanel>
               <apex:commandButton value="Add Product" action="{!toaddProduct}"/>
              
       </apex:pageBlockSection>

.......................

    

         <!--PRODUCT SECTION FOR ENTRY-->
            
            <apex:pageBlockSection title="Product Details" rendered="{!visible=='Step3'}">
            <apex:inputField value="{!Product.Name}"/>
           <!--<apex:inputField value="{!PricebookEntry.UnitPrice}"/>-->
            <apex:inputField value="{!QuoteLineItem.UnitPrice}"/>
            <apex:inputField value="{!QuoteLineItem.Quantity}"/>
             <apex:inputField value="{!QuoteLineItem.Discount}"/>
            <apex:inputCheckbox value="{!PricebookEntry.IsActive}"/>
           
            <apex:commandButton value="save" action="{!tosaveProduct}" style="float:left"/>
            
            </apex:pageBlockSection>

   </apex:page>

here is my controller code.....

 

public class pcontactdetailcontroller {

..................

.................

 public Quote quote{get;set;}

 public PricebookEntry pbentry{get;set;}
     public Pricebook2 pb{get;set;}
     public Product2 product{get;set;}
     public QuoteLineItem qutlineitem{get;set;}

 public Id quoteId{get;set;}

 

 public pcontactdetailcontroller() {

 pb= new Pricebook2();
      pbentry= new PricebookEntry(UseStandardPrice=true,UnitPrice=0.00);
      product=new Product2();
      qutlineitem=new QuoteLineItem();

}

 

 public Quote getQuote() {
       return quote;
       }

public Product2 getProduct2() {
    
        return product;
        }
     public Pricebook2 getPricebook2() {
    
        return pb;
        }
     public PricebookEntry getPricebookEntry() {
    
        return pbentry;
        }
     public QuoteLineItem getQuoteLineItem() {
    
       return qutlineitem;
       }

 

 
    //saving Quote and opening product entry section    
         
    public PageReference tosaveQuote() {
 
       quote.BillingName=contact.Account.Name;
       quote.ShippingName=contact.Account.Name;
       quote.ContactId =contact.Id;
       quote.Phone=contact.MobilePhone;
       quote.Email= contact.Email;
 
      // System.debug('########## quoteOpportunityId######'+ quote.OpportunityId);
       insert quote;
    
       visible='Step3';
   
    // insert quote1;
       return null;
       }
       
    //saving Product   
    
    
   public PageReference tosaveProduct() {
 
       insert product;
 
       pb.Name='Standard';
 
       insert pb;
       pbentry.Product2Id=product.Id;
       pbentry.Pricebook2Id=pb.Id;
    // pbentry.UnitPrice=0.00;  
    // pbentry.UseStandardPrice=true;
   
       insert pbentry;
       quote.Pricebook2Id=pb.Id;
       update quote;
       qutlineitem.PricebookEntryId = pbentry.Id;
       qutlineitem.quoteId=quote.Id;
       insert qutlineitem;
       visible=null;
       Id Id = ApexPages.currentPage().getParameters().get('Id');
       PageReference samepage= new PageReference('/apex/pcontactdetail?id='+id);
       samepage.setRedirect(true);
       return  samepage;
   }

 

 public PageReference forProduct() {
    
       quoteId = ApexPages.currentPage().getParameters().get('quoteId');
      quote1= [select Id,Name,(select Id,PricebookEntry.Product2.Name,UnitPrice,Quantity,Subtotal,Discount,TotalPrice From QuoteLineItems) from Quote where Id=:quoteId];
    
     asish = 'Show';
      return null;
   }

 public PageReference toaddProduct() {
       visible = 'Step3';
       return null;
       }
  }

I have sent necessary code at which I am facing problem.I have faced problem in the line

Update Quote;

kindly reply me as soon as possible...

 

Hi,

 

There seems to be some problem in VisualForce/Apex where it just won't assign values to elements of arrays if you access the elements by subscript number.   So weird.   Maybe I am not using correct syntax?   Please advise!!

 

 

//controller

public String[] someStrings {get;set;}

someStrings = new String[5];

//page

<apex:inputText value="{!someStrings[0]}">


// when using the syntax of someStrings[0], it compiles, but breaks somewhere before even running a method.  Is this a syntax issue or SF limitation??

 

Hi Friends,

I have one object record(Contact record) which has some Phone Fields, here I would like to check fetched Contact record field type as Phone. If true then I wish to access corresponding phone field values. Please can any one help on this issue?


Thanks,
Buss
  • February 14, 2014
  • Like
  • 0

Hi,

 

we have a java application which is connets to Salesforce. based on the some logic, I should set to Contact's Limit(Custom field- Integer type) field to "Null", then I have to update it using EnterpriseConnection. 

whereas i have updated from java as below

Contact.setLimit(null);

java Log shows null is assigned to Limit and succesful update command. but if i check in respective salesforce contact. it's not updated to null value.

 

whereas same code is working for all not null scenario's.

I have checked in salesforce there are no work flows and triggers not available on this field.

 

any help is appreciated.

 

Rgds,

Buss

 

 

  • June 11, 2013
  • Like
  • 0

Dear All,

 

I want to display in product detail page for every individual product the yearly sales like

 

Product 1 - 2008 -2,30,000

 2009 - 

  • November 22, 2012
  • Like
  • 0

Hi All,

 

i want to know is sales force support's ghost variable?

 

Rds,

Buss

  • June 05, 2012
  • Like
  • 0

Hi all,

 

any help is appreciation.

 

i have picklist status__c on contact object contains values "Active" and "In Active", so i want to display only active contacts on Account detail page.

 

i tried with below statement, it's showing error:

 

<apex:relatedList list="Contacts" title="Contacts" rendered="{!IF(ISPICKVAL(account.Contacts.status__c,'Active'), true, false)}" />

 

error:

Unknown property 'VisualforceArrayList.status__c'

 

Rds,

Buss


  • April 30, 2012
  • Like
  • 0

Hi All,

 

I need to track when ever Role Hierarchy chages based on which i have to assign values to Sales Reps.

 

Example:

Initialy A and B are Sales Managers, here X is reporting to A and Y is reporting to B for some period.

later my Role hierarchy is changed like, now Y is reporting to A and X is reporting to B.

 

Pls help if any one having any solution.

 

Rgds,

Buss

Certified Developer

  • February 17, 2012
  • Like
  • 0

Hi All,

 

i need to track role hierarchy changees.

 

example:

A and B are Sales Managers, here X is reporting to A and Y is reporting to B for some period.

later my Role hierarchy is changed like, now Y is reporting to A and X is reporting to B.

 

Then i want to track these changes on role hierarchy.

 

is this possible to track in salesforce.

 

Regds,

Buss

Cerified Developer

  • February 14, 2012
  • Like
  • 0

Hi,

 

Initially Company "Role Hirarchy" is defined and "Forecast" enabled then Sales targets are assigned monthwise.

after couple of months one Sales Rep reporting is changed to other Manager. Now my company SVP wants to see that Sales managers Forecast based reporting of that Sales Rep based time of actual work reporing, now earlier actuals(Achieved or Opportunity amount) should rollup to first manager and later should rollup to present Sales Manager.

 

Pls provide information that is there any solutions.

 

 

 

Rgds,

Buss

  • January 24, 2012
  • Like
  • 0

Hi All,

 

i want to know is there any way to get date format as 'DD MMM,YYYY'.i.e 20 Mar,2011.

if possibe, Pls can you explain how do i get that date format.

in my requirement having both Standard and Custom Pages on both Pages i need dispaly in "DD MMM,YYYY" Format dates.

 

Reds,

Buss

  • January 04, 2012
  • Like
  • 0

Hi,

 

How to find how users in my organisation are loggedin currently.

 

Rgds,

Buss

  • September 29, 2011
  • Like
  • 0

Hi all,

 

Below failure errors is showing while depolying to production, but while 'Run Tests'  no error is showing.

 

Failure Message: "System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, OpportunityTostageHistory: execution of BeforeInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Oppor...

 if i remove below code it's working fine.

if(AcSet.size()>0){
AcList = [SELECT id,Name,First_Oppty_Won__c FROM Account where id In:AcSet];
for(Account a:AcList){
a.First_Oppty_Won__c = a.First_Oppty_Won__c+1 ;
UAL.add(a);
}
update UAL;
}



below is complete code:

 

 

 

trigger OpportunityTostageHistory on Opportunity (before insert, after insert, before update)
{
    Set<Id> AcSet=new Set<Id>();
    List<Account> AcList;
    List<Account> UAL=new List<Account>();
         //variable to store old stage value to comparision
         String previousstage;
         List<Account> accs;
         //Query for the opportunity record types
         List<RecordType> rtypes = [Select Name, Id From RecordType
                      where sObjectType='Opportunity' and isActive=true];
         
         //Create a map between the Record Type Name and Id for easy retrieval
         Map<String,String> oppRecordTypes = new Map<String,String>{};
         for(RecordType rt: rtypes)
            oppRecordTypes.put(rt.Name,rt.Id);
           
         system.debug('%%%%%&&&&&&&&&&%%%%%%%%%%%%%%%%%%'+oppRecordTypes.get('Sales force'));
            String s3 = oppRecordTypes.get('Sales force');
            String qid = s3.substring(0,15);
            System.debug('$$$$$$$$$$$$^&&&&&&&&&&'+qid);
           
            /*-----Once Stage verbal apporval does not allow to previous stage----*/
            //create a map to opportunity stage and id's
            Map<String,Integer> mapp=new Map<String,Integer>();
            mapp.put('Call',01);
            mapp.put('Meeting',02);
            mapp.put('Demo',03);
            mapp.put('Custom Demo',04);
            mapp.put('Budget Validated',05);
            mapp.put('Need Analysis',06);
            mapp.put('Solution Proposed',07);
            mapp.put('POC Paid',08);
            mapp.put('POC unpaid',09);
            mapp.put('Written Proposal',10);
            mapp.put('Quote Approval',11);
            mapp.put('Verbal Approval',12);
            mapp.put('Request',13);
            mapp.put('Poc',14);
            mapp.put('Proposed',15);
            mapp.put('Negotiation',16);
            mapp.put('Closed/Lost',17);
            mapp.put('Closed/Won',17);    
       
 
 for(Opportunity I:Trigger.new)
   {  
     Stage__c  IV = new Stage__c ();
  
    if(trigger.isInsert){
   
       if(trigger.isBefore){
             if(I.StageName=='Closed/Won'){
                 AcSet.add(I.accountid);                                               
             }   
            }       
      
           //after insert functionality
          
            IV.Opportunity__c = I.Id ;
            IV.CloseDate__c =I.CloseDate ;
            IV.Amount__c = I.Amount ;
            IV.Comments_c__c = I.Comments__c ;
             
        
           system.debug('**********232323232********'+I.RecordTypeId+'@@@@@@@@@@@@'+I.StageName+'##########'+I.Vertical__c) ;
          
           IV.Name = I.StageName ;
      if(I.Vertical__c != null){
          if(I.Vertical__c == 'Sales force' || I.Vertical__c == 'MIDAS'){
         
           IV.Name = 'Call';
           IV.Probability__c = 5+'%' ;
          system.debug('**********'+IV.Name) ;
          }else if(I.Vertical__c == 'On-Demand Consulting' || I.Vertical__c == 'Projects'){
          IV.Name = 'Request';
          IV.Probability__c = 10+'%' ;
            system.debug('*****55555555*****'+IV.Name) ;
          }
         }
         
       //  if(I.RecordTypeId =='012T00000000bcg' || I.RecordTypeId =='012T00000000bcl'){
       //   if(I.RecordTypeId =='012F0000000qEF6' || I.RecordTypeId =='012F0000000qEF3'){
      if(I.RecordTypeId==oppRecordTypes.get('MIDAS') || I.RecordTypeId==oppRecordTypes.get('Sales force') || I.RecordTypeId==oppRecordTypes.get('IBM') ){
       
         if(IV.Name!= null){
             if(IV.Name == 'Call')
             {
                IV.Probability__c = 5+'%' ;
              
             }else If(IV.Name == 'Request'){
              IV.Probability__c = 10+'%' ;
             }
            }else{
             If(I.StageName == 'Call'){
                 IV.Probability__c = 5+'%' ;
                   }
            }
           
            If(I.StageName == 'Meeting'){
               IV.Probability__c = 10+'%' ;
            }else If(I.StageName == 'Demo'){
               IV.Probability__c = 15+'%' ;
            }else If(I.StageName == 'Custom Demo'){
               IV.Probability__c = 20+'%' ;
            }else If(I.StageName  == 'Budget Validated'){
               IV.Probability__c = 25+'%' ;
            } else If(I.StageName  == 'Need Analysis'){
               IV.Probability__c = 30+'%' ;
            } else If(I.StageName  == 'Solution Proposed'){
               IV.Probability__c = 40+'%' ;
            } else If(I.StageName  == 'POC Paid'){
               IV.Probability__c = 50+'%' ;
            } else If(I.StageName  == 'POC unpaid'){
               IV.Probability__c = 50+'%' ;
            } else If(I.StageName  == 'Written Proposal'){
               IV.Probability__c = 60+'%' ;
            }else If(I.StageName  == 'Quote Approval'){
               IV.Probability__c = 70+'%' ;
            }else If(I.StageName  == 'Verbal Approval'){
               IV.Probability__c = 80+'%' ;
            }else If(I.StageName  == 'Closed/Lost'){
               IV.Probability__c = 0+'%' ;
            }else If(I.StageName == 'Closed/Won'){
               IV.Probability__c = 100+'%' ;
            }
          
            }
        //   if(I.RecordTypeId  =='012T00000000bcq' || I.RecordTypeId  =='012T00000000bcv' ){ 
       //   if(I.RecordTypeId  =='012F0000000qEF4' || I.RecordTypeId  =='012F0000000qEF5' || I.RecordTypeId  =='012F0000000qEHn'){
    if(I.RecordTypeId==oppRecordTypes.get('On Demand Const') || I.RecordTypeId==oppRecordTypes.get('Projects') || I.RecordTypeId==oppRecordTypes.get('Others')){ 
            system.debug('**********11111*********'+I.RecordTypeId+'@@@@@@@@@@@@'+I.StageName) ;
             If(I.StageName == 'Request'){
             system.debug('*********222**********'+I.StageName);
                IV.Probability__c = 10+'%' ;
             }else If(I.StageName == 'Poc'){
               IV.Probability__c = 25+'%' ;
            }else If(I.StageName == 'Proposed'){
               IV.Probability__c = 50+'%' ;
            }else If(I.StageName == 'Negotiation'){
               IV.Probability__c = 75+'%' ;
            }else If(I.StageName == 'Closed/Won'){
               IV.Probability__c = 100+'%' ;
            }else If(I.StageName  == 'Closed/Lost'){
               IV.Probability__c = 0+'%' ;
            }
           
            }
          
        
          insert IV; 
    
      }
     
      if(trigger.isupdate){   
     
            if(I.Vertical__c!=null){
         
            I.Vertical__c = null ;
                  
           
            }else{
  
    List<Stage__c> s = [select Id,Name,Amount__c,Comments_c__c,Opportunity__c from Stage__c where Opportunity__c =:I.Id ];
   Integer inc =0 ;
  for(Stage__c s1 : s){
 
          if(s1.Amount__c == I.Amount && s1.Name == I.StageName && s1.Comments_c__c == I.Comments__c ){
         
          inc ++ ;
         
          }
    }
 
            IV.Opportunity__c = I.Id ;
            IV.CloseDate__c =I.CloseDate ;
            IV.Amount__c = I.Amount ;
            IV.Comments_c__c = I.Comments__c ;
            IV.Name = I.StageName ;
            
       //  if(I.RecordTypeId =='012T00000000bcg' || I.RecordTypeId =='012T00000000bcl'){ 
   //  if(I.RecordTypeId =='012F0000000qEF6' || I.RecordTypeId =='012F0000000qEF3'){
       if(I.RecordTypeId==oppRecordTypes.get('MIDAS') || I.RecordTypeId==oppRecordTypes.get('Sales force') || I.RecordTypeId==oppRecordTypes.get('IBM')){
            If(I.StageName == 'Call'){
         
               IV.Probability__c = 5+'%' ;
         
            }else If(I.StageName == 'Meeting'){
               IV.Probability__c = 10+'%' ;
            }else If(I.StageName == 'Demo'){
               IV.Probability__c = 15+'%' ;
            }else If(I.StageName == 'Custom Demo'){
               IV.Probability__c = 20+'%' ;
            }else If(I.StageName  == 'Budget Validated'){
               IV.Probability__c = 25+'%' ;
            } else If(I.StageName  == 'Need Analysis'){
               IV.Probability__c = 30+'%' ;
            } else If(I.StageName  == 'Solution Proposed'){
               IV.Probability__c = 40+'%' ;
            } else If(I.StageName  == 'POC Paid'){
               IV.Probability__c = 50+'%' ;
            } else If(I.StageName  == 'POC unpaid'){
               IV.Probability__c = 50+'%' ;
            } else If(I.StageName  == 'Written Proposal'){
               IV.Probability__c = 60+'%' ;
            }else If(I.StageName  == 'Quote Approval'){
               IV.Probability__c = 70+'%' ;
            }else If(I.StageName  == 'Verbal Approval'){
               IV.Probability__c = 80+'%' ;
            }else If(I.StageName  == 'Closed/Lost'){
               IV.Probability__c = 0+'%' ;
            }else If(I.StageName == 'Closed/Won'){
               IV.Probability__c = 100+'%' ;
               AcSet.add(I.accountid);
              
            }
          
            }
        //      if(I.RecordTypeId  =='012T00000000bcq' || I.RecordTypeId  =='012T00000000bcv' ){ 
         //   if(I.RecordTypeId  =='012F0000000qEF4' || I.RecordTypeId  =='012F0000000qEF5' || I.RecordTypeId  =='012F0000000qEHn'){
      if(I.RecordTypeId==oppRecordTypes.get('On Demand Const') || I.RecordTypeId==oppRecordTypes.get('Projects') || I.RecordTypeId==oppRecordTypes.get('Others')){ 
      
           
             If(I.StageName == 'Request'){
                IV.Probability__c = 10+'%' ;
             }else If(I.StageName == 'Poc'){
               IV.Probability__c = 25+'%' ;
            }else If(I.StageName == 'Proposed'){
               IV.Probability__c = 50+'%' ;
            }else If(I.StageName == 'Negotiation'){
               IV.Probability__c = 75+'%' ;
            }else If(I.StageName == 'Closed/Won'){
               IV.Probability__c = 100+'%' ;
               AcSet.add(I.accountid);
              
            }else If(I.StageName  == 'Closed/Lost'){
               IV.Probability__c = 0+'%' ;
            }
           
            }
           
          if(inc != 1 )   
            {
              insert IV;
            }
       
         
      }
     
           //to retrieve old opportunity stage value
        for(Opportunity l1:Trigger.old){
            previousstage=l1.StageName;
            //prevForeCastCatg=l1.ForecastCategoryName;
           
        }
       
        //for each new insert opportunity stage
       
            System.debug('@@@@@@@@@@@@@@@@@@@@@@@@@**************'+previousstage);
           
            if(previousstage == 'Verbal Approval' || previousstage == 'Negotiation' || previousstage == 'Closed/Won' || previousstage == 'Closed/Lost'){
                System.debug('Previous fore cast catagory is commit or Closed/Won or Closed/Lost is enterd'+previousstage);          
                if(!(mapp.get(previousstage)<mapp.get(I.StageName))){
                    if(previousstage == 'Closed/Won'){
                        I.StageName.addError('Opportunity already Closed/Won');
                    }else if(previousstage == 'Closed/Lost'){
                         I.StageName.addError('Opportunity already Closed/Lost');
                    }
                    else{
                        I.StageName.addError('Please Select the Next Stage');
                    }
                }
               
            }
      
     }
      
            
   }   
   if(AcSet.size()>0){
       AcList = [SELECT id,Name,First_Oppty_Won__c FROM Account where id In:AcSet];
       for(Account a:AcList){
           a.First_Oppty_Won__c = a.First_Oppty_Won__c+1 ;
           UAL.add(a);
       }
       update UAL;            
   }
}

 

 

  • July 01, 2011
  • Like
  • 0

Hi all,

 

I have orgnisation role hierarchy were each individual user is having respective Quotas,here i want to roll up Quota's of all users in the hierarchy to the SVP Role.

Please Help any one know, i want to any feature to do this.

 

regards,

Nchikka.

  • May 10, 2011
  • Like
  • 0

Hi all,

 

 

Please Help in sales force forecast Tab issue like below,

 

i have four users under Vice president role  the four have thier bussiness plan target month wise i set in their forecast  target fore six months like set up--> admin set up--->manage users-->users--> for user enabled check box of "allow forecasting " then i got quotas related list.

 

in  Quota i set month wise forecast targets.

 

Now i want in Forecast Tab-------->for Vice president role user --------->In Direct Report section--------->

for Vice president role user should show month wise target as sum of amounts of below hierarchy users(Four Users).

 

regards,

nchikka.

 

 

  • May 09, 2011
  • Like
  • 0

hi all,

 

i am beginer to force platform need help.while creating the roles i am view and edit roles names and setting please help as you know.

i think some where i restricted field level access permissions.but unable to find.

 

  • August 14, 2010
  • Like
  • 0

Hi,

 

Here Im trying to create a trigger where there is master object (Custom object-Opportunity) and child object(RFP).

Im mapping values from other object (Ratecard) when i entered some parameters in RFP.

In RFP there are some parameters(CompletesRequired,BID,Incidence rate,Market,Audience,Ratecard).We have same fields in Ratecard object with Actual CPI (currency) which we are uploading through dataloader.

When i entered these parameters in RFP the ActualCpi will populate automatically in RFP Object.

this scenario is working for one RFP entry.How can i use lists in this case for multiple rfp entry.

 

trigger RFPupdate on RFP__c (before insert, before update) {
 
 
Set<Decimal> comp = new Set<Decimal>();
Set<Decimal> bid  = new Set<Decimal>();
Set<Decimal> inc  = new Set<Decimal>();
List<String> aud  = new List<String>();
List<String> stage = new List<String>();
List<String> stage2 = new List<String>();
List<String> market=new List<String>();
List<String> ratecard =new List<String>();
List<Id> opp=new List<Id>();
 
for(RFP__c r : trigger.new){
 
 
    if(r.Completes_Required__c != null){
        comp.add(r.Completes_Required__c);
       } 
    if(r.Bid_LOI_in_minutes__c != null){ 
        bid.add(r.Bid_LOI_in_minutes__c);
        }
    if(r.Incidence_Rate__c != null)
    {
        inc.add(r.Incidence_Rate__c);
     }
    if((r.Audience__c == 'B2B' || r.Audience__c == 'Gen Pop') && r.Stage__c == 'RFP_Received')
    {    
        aud.add(r.Audience__c);
    }
    if(r.Market__c != null)
    {
        market.add(r.Market__c);
    }
   if(r.Rate_Card__c != null)
   {
     ratecard.add(r.Rate_Card__c);
   }
   if(r.Opportunity__c!=null)
   {
      opp.add(r.Opportunity__c);
      system.debug('Opp*****'+opp);
   }
}
 
//If audience is B2B or Genpop
try{
if(aud.size()> 0){
    Map<Decimal, CPI__c> cpi1 = new Map<Decimal, CPI__c>();
 
    for(CPI__c obj1 : [SELECT Id, Bid_LOI_in_minutes__c,Actual_CPI__c,Incidence_Rate__c,Actual_CPIchanged__c,Audience__c,Stage__c, Completes_Required__c,Name,Market__c  FROM CPI__c WHERE    (Bid_LOI_in_minutes__c IN :bid
                               AND  Completes_Required__c IN: comp AND Incidence_Rate__c IN:inc AND Audience__c IN:aud AND Name IN:ratecard AND Market__c IN:market  )]){
        cpi1.put(obj1.Completes_Required__c , obj1);
        system.debug('CPI'+cpi1);
    }
 
    // We have all the reference data we need, last loop on the each Opportunity
 
    if(cpi1.size()>0){
    
       system.debug('CPISize@@@@@@@'+cpi1.size());
        for(RFP__c rf1: trigger.new){
         
                system.debug('^^^^^^^^^^^^^^^RFP'+rf1);
                rf1.Actual_CPI__c = cpi1.get(rf1.Completes_Required__c).Actual_CPIchanged__c;
                   system.debug('ActualCPI################'+rf1.Actual_CPI__c);
                    if(rf1.Proposed_CPI__c == 0.00 ){
                        rf1.Proposed_CPI__c= cpi1.get(rf1.Completes_Required__c).Actual_CPIchanged__c;
                        system.debug('ProposedCPI##############'+rf1.Proposed_CPI__c);
                    }
                               
       
        
        }
    
   } 
    else{
        for(RFP__c  rf1 : trigger.new){
            
               rf1.Actual_CPI__c =0.00;
            
        }      
    }
}    
}
 
catch(exception e){
}
 
}
  • October 16, 2013
  • Like
  • 0

Hi All,

 

i want to know is sales force support's ghost variable?

 

Rds,

Buss

  • June 05, 2012
  • Like
  • 0

Hi All,

 

i need to track role hierarchy changees.

 

example:

A and B are Sales Managers, here X is reporting to A and Y is reporting to B for some period.

later my Role hierarchy is changed like, now Y is reporting to A and X is reporting to B.

 

Then i want to track these changes on role hierarchy.

 

is this possible to track in salesforce.

 

Regds,

Buss

Cerified Developer

  • February 14, 2012
  • Like
  • 0

Hi,

 

i have an custom object INDIVIDUAL CUSTOMER:-

In this object i have a picklist field Customer Type: 1> mechanic 2> Reborer 3> Retailer.

Now based on this Customer type there should be a unique field having the unique id say contact id.

 

For Eg:-  If the customer type is MECHANIC then the unique id field should be like {MEC-0000}

                 If the customer type is REBRER then the unique id field should be like {REB-0000}

                  If the customer type is RETAILER then the unique id field should be like {RET-0000}

 

Also, for each next Record created for mechanic it should be MEC-0000 then MEC-0001,MEC-0002 in the uniqueid field(contact id).

Simmilarly, 

                     for each next Record created for Rebrorer it should be REB-0000 then REB-0001,REB-0002 in the uniqueid field(contact id).

                     for each next Record created for RETAILER it should be RET-0000 then RET-0001,RET-0002 in the uniqueid field(contact id).


 

Can Anybody tell me how i can override standard button of every object with same Visualforce page?

i want same vf page for every object edit layout..

 

help..

Hi All,

    How to use more than one zip code in query , iam getting error.

 

Select Id, PostalCode FROM Lead WHERE IsConverted = false AND PostalCode like ('%32814%' ,'%32816%','%32819%')

Hi all,

     i have one object called leaves.In this we have to calculate the no of used days quarterly wize.

i.e.,from date,To date two date fields.Based on the from date,to date  two values are entered then no of days obtained.

no.of.days=todate-fromdate+1; and these no of days are calculated based on quarterly wize. Any one can u please help me this.

 

 

Thanks in advance

Hi,

 

I have 2 custom objects. I am creating the many to many relationship with these two objects. Now i am get the junction object related list in two objects. Now i want to rename the standard new button name( which in related list of main objects. Please any one help me for solving this.

 

 

Thanks,

Lakshmi.

Hi All,

 

i want to know is there any way to get date format as 'DD MMM,YYYY'.i.e 20 Mar,2011.

if possibe, Pls can you explain how do i get that date format.

in my requirement having both Standard and Custom Pages on both Pages i need dispaly in "DD MMM,YYYY" Format dates.

 

Reds,

Buss

  • January 04, 2012
  • Like
  • 0

Hi Everyone

I want to add more product in a perticular Quote.I know the relationship between Quote,QuoteLineItem ,Pricebook2,Product2 and PricebookEntry.my first product is saved but when I am  trying to add more product under a perticular Quote an error is fired.

"Id is not specified in an update call.."  .I have written update statement to update Quote because there is a required field Pricebook2Id in Quote.when I  am creating a new product at that time assisgning a unit price through PricebookEntry.Because Product2 and Pricebook2 are related in a many to many relationship and the junction object is PricebookEntry.

My problem is that how can we update PricebookId field In Quote each time when a Product is created.

That means there is one record in Quote but I have to created more product inside perticular Quote.

 

I am beginner in salesforce.May be I canot express my problem.So I request please help me in a simpler way....

Here is my code.

 

<apex:page controller= pcontactdetailcontroller>

................

...............

 

       <!----QUOTE table-->
  <apex:pageBlockSection title="Quote Details of a Perctcular Opportunity" rendered="{!table=='Show'}">
           
                <B>OPPORTUNITY NAME:&nbsp;{!Opportunity1.Name}</B>
            <!--<apex:outputField label="OPPORTUNITY" value="{!OpportunityContactRoles.Opportunity.Name}"/>-->
              <apex:outputPanel style="float:middle">
                  <p><B> All Quotes </B></P>
                 <apex:dataTable value="{!Opportunity1.Quotes}" var="Qut" cellpadding="2" border="1"  rowClasses="odd,even" >
           
                    <apex:column headerValue="Quote Name">
                    <apex:commandLink value="{!Qut.Name}"  title="to see product" style="font-size:15;color:blue;" action="{!forProduct}">
                     <apex:param name="quoteId" value="{!Qut.Id}"/>
                     </apex:commandLink>
                    </apex:column>
                     <apex:column headerValue="Status">{!Qut.Status}</apex:column>
               
                   </apex:dataTable>
                  </apex:outputPanel>
                  <apex:commandButton value="Add Quote" action="{!toaddQoute}"/>
             </apex:pageBlockSection>

 

 <!--product table------>
                 <apex:pageBlockSection title="Product Details" rendered="{!asish=='Show'}">
            
                  <B>OPPORTUNITY NAME:&nbsp;{!Opportunity1.Name}</B><br/><br/>
                  <B>QUOTE NAME:&nbsp;{!Quote1.Name}</B>
               <apex:outputPanel style="float:middle">
                  <p><B> Product Details </B></P>
                  <apex:datatable value="{!quote1.QuoteLineItems}" var="pdct" cellpadding="2" border="1"  rowClasses="odd,even">
                  <apex:column headerValue="Product Name">{!pdct.PricebookEntry.Product2.Name}</apex:column>
                  <apex:column headerValue="Unit Price">{!pdct.UnitPrice}</apex:column>
                  <apex:column headerValue="Quantity">{!pdct.Quantity}</apex:column>
                  <apex:column headerValue="Sub Total">"{!pdct.Subtotal}</apex:column>
                  <apex:column headerValue="Discount">"{!pdct.Discount}</apex:column>
                  <apex:column headerValue="TotalPrice">{!pdct.TotalPrice}</apex:column>
                  
                  </apex:datatable>
                  
               </apex:outputPanel>
               <apex:commandButton value="Add Product" action="{!toaddProduct}"/>
              
       </apex:pageBlockSection>

.......................

    

         <!--PRODUCT SECTION FOR ENTRY-->
            
            <apex:pageBlockSection title="Product Details" rendered="{!visible=='Step3'}">
            <apex:inputField value="{!Product.Name}"/>
           <!--<apex:inputField value="{!PricebookEntry.UnitPrice}"/>-->
            <apex:inputField value="{!QuoteLineItem.UnitPrice}"/>
            <apex:inputField value="{!QuoteLineItem.Quantity}"/>
             <apex:inputField value="{!QuoteLineItem.Discount}"/>
            <apex:inputCheckbox value="{!PricebookEntry.IsActive}"/>
           
            <apex:commandButton value="save" action="{!tosaveProduct}" style="float:left"/>
            
            </apex:pageBlockSection>

   </apex:page>

here is my controller code.....

 

public class pcontactdetailcontroller {

..................

.................

 public Quote quote{get;set;}

 public PricebookEntry pbentry{get;set;}
     public Pricebook2 pb{get;set;}
     public Product2 product{get;set;}
     public QuoteLineItem qutlineitem{get;set;}

 public Id quoteId{get;set;}

 

 public pcontactdetailcontroller() {

 pb= new Pricebook2();
      pbentry= new PricebookEntry(UseStandardPrice=true,UnitPrice=0.00);
      product=new Product2();
      qutlineitem=new QuoteLineItem();

}

 

 public Quote getQuote() {
       return quote;
       }

public Product2 getProduct2() {
    
        return product;
        }
     public Pricebook2 getPricebook2() {
    
        return pb;
        }
     public PricebookEntry getPricebookEntry() {
    
        return pbentry;
        }
     public QuoteLineItem getQuoteLineItem() {
    
       return qutlineitem;
       }

 

 
    //saving Quote and opening product entry section    
         
    public PageReference tosaveQuote() {
 
       quote.BillingName=contact.Account.Name;
       quote.ShippingName=contact.Account.Name;
       quote.ContactId =contact.Id;
       quote.Phone=contact.MobilePhone;
       quote.Email= contact.Email;
 
      // System.debug('########## quoteOpportunityId######'+ quote.OpportunityId);
       insert quote;
    
       visible='Step3';
   
    // insert quote1;
       return null;
       }
       
    //saving Product   
    
    
   public PageReference tosaveProduct() {
 
       insert product;
 
       pb.Name='Standard';
 
       insert pb;
       pbentry.Product2Id=product.Id;
       pbentry.Pricebook2Id=pb.Id;
    // pbentry.UnitPrice=0.00;  
    // pbentry.UseStandardPrice=true;
   
       insert pbentry;
       quote.Pricebook2Id=pb.Id;
       update quote;
       qutlineitem.PricebookEntryId = pbentry.Id;
       qutlineitem.quoteId=quote.Id;
       insert qutlineitem;
       visible=null;
       Id Id = ApexPages.currentPage().getParameters().get('Id');
       PageReference samepage= new PageReference('/apex/pcontactdetail?id='+id);
       samepage.setRedirect(true);
       return  samepage;
   }

 

 public PageReference forProduct() {
    
       quoteId = ApexPages.currentPage().getParameters().get('quoteId');
      quote1= [select Id,Name,(select Id,PricebookEntry.Product2.Name,UnitPrice,Quantity,Subtotal,Discount,TotalPrice From QuoteLineItems) from Quote where Id=:quoteId];
    
     asish = 'Show';
      return null;
   }

 public PageReference toaddProduct() {
       visible = 'Step3';
       return null;
       }
  }

I have sent necessary code at which I am facing problem.I have faced problem in the line

Update Quote;

kindly reply me as soon as possible...

 

Hi All,

 

I need to convert DateTime field  2011-03-21T11:54:45.000Z to Date Format. March 21, 2011

 

Thanks,

Krishna

  • August 11, 2011
  • Like
  • 0

Can someone please help me with creating an add new button for a custom object and custom edit page?

four object is there 

1)job

2)job task

(master detail relationship between Job(master) and job task(Detail))


3)Schedule Template

4)Schedule Task

(master detail relationship between Schedule Template(master) and Schedule task(Detail))


all fields on job task and schedule tasks are same(except relational part)


one more thing is, there is lookup relationship between job(detail) and schedule template(master)...I want that when I select any schedule template on any job page then all the schedule task related to that particular schedule template should be copied into Job tAsk.(How to make trigger on job)


Hi,

 

There seems to be some problem in VisualForce/Apex where it just won't assign values to elements of arrays if you access the elements by subscript number.   So weird.   Maybe I am not using correct syntax?   Please advise!!

 

 

//controller

public String[] someStrings {get;set;}

someStrings = new String[5];

//page

<apex:inputText value="{!someStrings[0]}">


// when using the syntax of someStrings[0], it compiles, but breaks somewhere before even running a method.  Is this a syntax issue or SF limitation??

 

Hi all,

 

Below failure errors is showing while depolying to production, but while 'Run Tests'  no error is showing.

 

Failure Message: "System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, OpportunityTostageHistory: execution of BeforeInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Oppor...

 if i remove below code it's working fine.

if(AcSet.size()>0){
AcList = [SELECT id,Name,First_Oppty_Won__c FROM Account where id In:AcSet];
for(Account a:AcList){
a.First_Oppty_Won__c = a.First_Oppty_Won__c+1 ;
UAL.add(a);
}
update UAL;
}



below is complete code:

 

 

 

trigger OpportunityTostageHistory on Opportunity (before insert, after insert, before update)
{
    Set<Id> AcSet=new Set<Id>();
    List<Account> AcList;
    List<Account> UAL=new List<Account>();
         //variable to store old stage value to comparision
         String previousstage;
         List<Account> accs;
         //Query for the opportunity record types
         List<RecordType> rtypes = [Select Name, Id From RecordType
                      where sObjectType='Opportunity' and isActive=true];
         
         //Create a map between the Record Type Name and Id for easy retrieval
         Map<String,String> oppRecordTypes = new Map<String,String>{};
         for(RecordType rt: rtypes)
            oppRecordTypes.put(rt.Name,rt.Id);
           
         system.debug('%%%%%&&&&&&&&&&%%%%%%%%%%%%%%%%%%'+oppRecordTypes.get('Sales force'));
            String s3 = oppRecordTypes.get('Sales force');
            String qid = s3.substring(0,15);
            System.debug('$$$$$$$$$$$$^&&&&&&&&&&'+qid);
           
            /*-----Once Stage verbal apporval does not allow to previous stage----*/
            //create a map to opportunity stage and id's
            Map<String,Integer> mapp=new Map<String,Integer>();
            mapp.put('Call',01);
            mapp.put('Meeting',02);
            mapp.put('Demo',03);
            mapp.put('Custom Demo',04);
            mapp.put('Budget Validated',05);
            mapp.put('Need Analysis',06);
            mapp.put('Solution Proposed',07);
            mapp.put('POC Paid',08);
            mapp.put('POC unpaid',09);
            mapp.put('Written Proposal',10);
            mapp.put('Quote Approval',11);
            mapp.put('Verbal Approval',12);
            mapp.put('Request',13);
            mapp.put('Poc',14);
            mapp.put('Proposed',15);
            mapp.put('Negotiation',16);
            mapp.put('Closed/Lost',17);
            mapp.put('Closed/Won',17);    
       
 
 for(Opportunity I:Trigger.new)
   {  
     Stage__c  IV = new Stage__c ();
  
    if(trigger.isInsert){
   
       if(trigger.isBefore){
             if(I.StageName=='Closed/Won'){
                 AcSet.add(I.accountid);                                               
             }   
            }       
      
           //after insert functionality
          
            IV.Opportunity__c = I.Id ;
            IV.CloseDate__c =I.CloseDate ;
            IV.Amount__c = I.Amount ;
            IV.Comments_c__c = I.Comments__c ;
             
        
           system.debug('**********232323232********'+I.RecordTypeId+'@@@@@@@@@@@@'+I.StageName+'##########'+I.Vertical__c) ;
          
           IV.Name = I.StageName ;
      if(I.Vertical__c != null){
          if(I.Vertical__c == 'Sales force' || I.Vertical__c == 'MIDAS'){
         
           IV.Name = 'Call';
           IV.Probability__c = 5+'%' ;
          system.debug('**********'+IV.Name) ;
          }else if(I.Vertical__c == 'On-Demand Consulting' || I.Vertical__c == 'Projects'){
          IV.Name = 'Request';
          IV.Probability__c = 10+'%' ;
            system.debug('*****55555555*****'+IV.Name) ;
          }
         }
         
       //  if(I.RecordTypeId =='012T00000000bcg' || I.RecordTypeId =='012T00000000bcl'){
       //   if(I.RecordTypeId =='012F0000000qEF6' || I.RecordTypeId =='012F0000000qEF3'){
      if(I.RecordTypeId==oppRecordTypes.get('MIDAS') || I.RecordTypeId==oppRecordTypes.get('Sales force') || I.RecordTypeId==oppRecordTypes.get('IBM') ){
       
         if(IV.Name!= null){
             if(IV.Name == 'Call')
             {
                IV.Probability__c = 5+'%' ;
              
             }else If(IV.Name == 'Request'){
              IV.Probability__c = 10+'%' ;
             }
            }else{
             If(I.StageName == 'Call'){
                 IV.Probability__c = 5+'%' ;
                   }
            }
           
            If(I.StageName == 'Meeting'){
               IV.Probability__c = 10+'%' ;
            }else If(I.StageName == 'Demo'){
               IV.Probability__c = 15+'%' ;
            }else If(I.StageName == 'Custom Demo'){
               IV.Probability__c = 20+'%' ;
            }else If(I.StageName  == 'Budget Validated'){
               IV.Probability__c = 25+'%' ;
            } else If(I.StageName  == 'Need Analysis'){
               IV.Probability__c = 30+'%' ;
            } else If(I.StageName  == 'Solution Proposed'){
               IV.Probability__c = 40+'%' ;
            } else If(I.StageName  == 'POC Paid'){
               IV.Probability__c = 50+'%' ;
            } else If(I.StageName  == 'POC unpaid'){
               IV.Probability__c = 50+'%' ;
            } else If(I.StageName  == 'Written Proposal'){
               IV.Probability__c = 60+'%' ;
            }else If(I.StageName  == 'Quote Approval'){
               IV.Probability__c = 70+'%' ;
            }else If(I.StageName  == 'Verbal Approval'){
               IV.Probability__c = 80+'%' ;
            }else If(I.StageName  == 'Closed/Lost'){
               IV.Probability__c = 0+'%' ;
            }else If(I.StageName == 'Closed/Won'){
               IV.Probability__c = 100+'%' ;
            }
          
            }
        //   if(I.RecordTypeId  =='012T00000000bcq' || I.RecordTypeId  =='012T00000000bcv' ){ 
       //   if(I.RecordTypeId  =='012F0000000qEF4' || I.RecordTypeId  =='012F0000000qEF5' || I.RecordTypeId  =='012F0000000qEHn'){
    if(I.RecordTypeId==oppRecordTypes.get('On Demand Const') || I.RecordTypeId==oppRecordTypes.get('Projects') || I.RecordTypeId==oppRecordTypes.get('Others')){ 
            system.debug('**********11111*********'+I.RecordTypeId+'@@@@@@@@@@@@'+I.StageName) ;
             If(I.StageName == 'Request'){
             system.debug('*********222**********'+I.StageName);
                IV.Probability__c = 10+'%' ;
             }else If(I.StageName == 'Poc'){
               IV.Probability__c = 25+'%' ;
            }else If(I.StageName == 'Proposed'){
               IV.Probability__c = 50+'%' ;
            }else If(I.StageName == 'Negotiation'){
               IV.Probability__c = 75+'%' ;
            }else If(I.StageName == 'Closed/Won'){
               IV.Probability__c = 100+'%' ;
            }else If(I.StageName  == 'Closed/Lost'){
               IV.Probability__c = 0+'%' ;
            }
           
            }
          
        
          insert IV; 
    
      }
     
      if(trigger.isupdate){   
     
            if(I.Vertical__c!=null){
         
            I.Vertical__c = null ;
                  
           
            }else{
  
    List<Stage__c> s = [select Id,Name,Amount__c,Comments_c__c,Opportunity__c from Stage__c where Opportunity__c =:I.Id ];
   Integer inc =0 ;
  for(Stage__c s1 : s){
 
          if(s1.Amount__c == I.Amount && s1.Name == I.StageName && s1.Comments_c__c == I.Comments__c ){
         
          inc ++ ;
         
          }
    }
 
            IV.Opportunity__c = I.Id ;
            IV.CloseDate__c =I.CloseDate ;
            IV.Amount__c = I.Amount ;
            IV.Comments_c__c = I.Comments__c ;
            IV.Name = I.StageName ;
            
       //  if(I.RecordTypeId =='012T00000000bcg' || I.RecordTypeId =='012T00000000bcl'){ 
   //  if(I.RecordTypeId =='012F0000000qEF6' || I.RecordTypeId =='012F0000000qEF3'){
       if(I.RecordTypeId==oppRecordTypes.get('MIDAS') || I.RecordTypeId==oppRecordTypes.get('Sales force') || I.RecordTypeId==oppRecordTypes.get('IBM')){
            If(I.StageName == 'Call'){
         
               IV.Probability__c = 5+'%' ;
         
            }else If(I.StageName == 'Meeting'){
               IV.Probability__c = 10+'%' ;
            }else If(I.StageName == 'Demo'){
               IV.Probability__c = 15+'%' ;
            }else If(I.StageName == 'Custom Demo'){
               IV.Probability__c = 20+'%' ;
            }else If(I.StageName  == 'Budget Validated'){
               IV.Probability__c = 25+'%' ;
            } else If(I.StageName  == 'Need Analysis'){
               IV.Probability__c = 30+'%' ;
            } else If(I.StageName  == 'Solution Proposed'){
               IV.Probability__c = 40+'%' ;
            } else If(I.StageName  == 'POC Paid'){
               IV.Probability__c = 50+'%' ;
            } else If(I.StageName  == 'POC unpaid'){
               IV.Probability__c = 50+'%' ;
            } else If(I.StageName  == 'Written Proposal'){
               IV.Probability__c = 60+'%' ;
            }else If(I.StageName  == 'Quote Approval'){
               IV.Probability__c = 70+'%' ;
            }else If(I.StageName  == 'Verbal Approval'){
               IV.Probability__c = 80+'%' ;
            }else If(I.StageName  == 'Closed/Lost'){
               IV.Probability__c = 0+'%' ;
            }else If(I.StageName == 'Closed/Won'){
               IV.Probability__c = 100+'%' ;
               AcSet.add(I.accountid);
              
            }
          
            }
        //      if(I.RecordTypeId  =='012T00000000bcq' || I.RecordTypeId  =='012T00000000bcv' ){ 
         //   if(I.RecordTypeId  =='012F0000000qEF4' || I.RecordTypeId  =='012F0000000qEF5' || I.RecordTypeId  =='012F0000000qEHn'){
      if(I.RecordTypeId==oppRecordTypes.get('On Demand Const') || I.RecordTypeId==oppRecordTypes.get('Projects') || I.RecordTypeId==oppRecordTypes.get('Others')){ 
      
           
             If(I.StageName == 'Request'){
                IV.Probability__c = 10+'%' ;
             }else If(I.StageName == 'Poc'){
               IV.Probability__c = 25+'%' ;
            }else If(I.StageName == 'Proposed'){
               IV.Probability__c = 50+'%' ;
            }else If(I.StageName == 'Negotiation'){
               IV.Probability__c = 75+'%' ;
            }else If(I.StageName == 'Closed/Won'){
               IV.Probability__c = 100+'%' ;
               AcSet.add(I.accountid);
              
            }else If(I.StageName  == 'Closed/Lost'){
               IV.Probability__c = 0+'%' ;
            }
           
            }
           
          if(inc != 1 )   
            {
              insert IV;
            }
       
         
      }
     
           //to retrieve old opportunity stage value
        for(Opportunity l1:Trigger.old){
            previousstage=l1.StageName;
            //prevForeCastCatg=l1.ForecastCategoryName;
           
        }
       
        //for each new insert opportunity stage
       
            System.debug('@@@@@@@@@@@@@@@@@@@@@@@@@**************'+previousstage);
           
            if(previousstage == 'Verbal Approval' || previousstage == 'Negotiation' || previousstage == 'Closed/Won' || previousstage == 'Closed/Lost'){
                System.debug('Previous fore cast catagory is commit or Closed/Won or Closed/Lost is enterd'+previousstage);          
                if(!(mapp.get(previousstage)<mapp.get(I.StageName))){
                    if(previousstage == 'Closed/Won'){
                        I.StageName.addError('Opportunity already Closed/Won');
                    }else if(previousstage == 'Closed/Lost'){
                         I.StageName.addError('Opportunity already Closed/Lost');
                    }
                    else{
                        I.StageName.addError('Please Select the Next Stage');
                    }
                }
               
            }
      
     }
      
            
   }   
   if(AcSet.size()>0){
       AcList = [SELECT id,Name,First_Oppty_Won__c FROM Account where id In:AcSet];
       for(Account a:AcList){
           a.First_Oppty_Won__c = a.First_Oppty_Won__c+1 ;
           UAL.add(a);
       }
       update UAL;            
   }
}

 

 

  • July 01, 2011
  • Like
  • 0