• Raghu nathan
  • NEWBIE
  • 25 Points
  • Member since 2014

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
Hi,
 I have two picklist fileds called Approval Status with Values "Committed, Approved" and Proposal Type with values "Quote and Order" on same object. 
And I have custom button called Convert To Order on detail page, if I click on Convert to Order but it should check with Approval Status field if it is having field value is Approved then Proposal Type should be changed to Order value.
for this I have created a custom button and added JavaScript OnClick event as below. 

{!IF( ISPICKVAL( Custom_Object__c.Approval_Status__c , 'Approved'),
       TEXT( Custom_Object__c.Proposal_Type__c )='Order' ,'Quote')}

But it's not working when I click the button
public with sharing class AMMainContactCtrl {
    private final ApexPages.StandardController controller;
    public Contact mainContact {get; set;}
    public Boolean patientMainCnct {get; set;}
    public Boolean prMainCnct {get; set;}
    
    public Boolean isReferrer{get;set;}
    public String fullName{get;set;}
    public String ph1{get;set;}
    public String ph2{get;set;}
    public String fax{get;set;}
    public String email{get;set;}
    public String clvm{get;set;}
    public String bttc{get;set;}
    public String bdm{get;set;}
    public String tz{get;set;}
    public String rlnshp{get;set;}
    
    public AMMainContactCtrl(ApexPages.StandardController controller) {
         this.controller = controller;
         this.mainContact = (Contact)controller.getRecord();
         system.debug(this.mainContact);
         patientMainCnct = false;
         prMainCnct = false;
    }
    
    public AMMainContactCtrl() {
        
    }
    
    public PageReference getMainCnctInfo() {
        try {
               system.debug(mainContact);
            if(mainContact!=null) {
            system.debug('after main if loop');
                Contact cntct = [Select name,phone,MobilePhone,fax,email,check_box__c,LastCURequestDate,LastCUUpdateDate,LeadSource,Accountid,contact_person__c from Contact where id=:mainContact.Id];
                    if(cntct!=null) {
                        system.debug('after one more if loop');
                           system.debug(cntct.contact_person__c+'hello');
                        if(cntct.contact_person__c) {
                            system.debug('after two if loop');
                            fullName = cntct.name;
                            ph1 = cntct.Phone;
                            ph2 = cntct.MobilePhone;
                            fax = cntct.Fax;
                            email = cntct.Email;
                            if(cntct.check_box__c)
                                clvm = 'Yes';
                            else clvm = 'No';
                            bttc = String.valueOf(cntct.LastCURequestDate);
                            bdm = String.valueOf(cntct.LastCUUpdateDate);
                            tz = String.valueOf(cntct.LeadSource);
                            rlnshp = String.valueOf(cntct.Account);
                              system.debug('end');
                           
                    } else {
                       fullName = cntct.name;
                            ph1 = cntct.Phone;
                            ph2 = cntct.MobilePhone;
                            fax = cntct.Fax;
                            email = cntct.Email;
                            if(cntct.check_box__c)
                                clvm = 'Yes';
                            else clvm = 'No';
                            bttc = String.valueOf(cntct.LastCURequestDate);
                            bdm = String.valueOf(cntct.LastCUUpdateDate);
                            tz = String.valueOf(cntct.LeadSource);
                            rlnshp = String.valueOf(cntct.Account);      
                    }
                }
            }
        } catch(Exception ex) {
            System.debug('\n\nException in getMainCnctInfo: ' + ex.getMessage() + ' : ' + ex.getLineNumber());
        }
        return null;
    }

}
Hi,
 I have two picklist fileds called Approval Status with Values "Committed, Approved" and Proposal Type with values "Quote and Order" on same object. 
And I have custom button called Convert To Order on detail page, if I click on Convert to Order but it should check with Approval Status field if it is having field value is Approved then Proposal Type should be changed to Order value.
for this I have created a custom button and added JavaScript OnClick event as below. 

{!IF( ISPICKVAL( Custom_Object__c.Approval_Status__c , 'Approved'),
       TEXT( Custom_Object__c.Proposal_Type__c )='Order' ,'Quote')}

But it's not working when I click the button