• Dorababu
  • NEWBIE
  • 25 Points
  • Member since 2013

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 24
    Questions
  • 8
    Replies

Hi,

I have overriden the delete link of a custom object to redirect to a custom vf page. The custom page shows the members associated with the custom object. When members are associated delete is not possible - user has to remove members and then delete the record of custom object. The problem is when there are no members associated with the object even then user is redirected to custom page. I need to have a control on redirect such that, only when members are associated, redirect happens and when members are not associated redirect should not happen and selected record should be deleted.

Any solution would be appreciated.

Hi,

I have enabled person account in my org. I have created record types in Leads - Person Leads and Business Leads.

When converting a lead to account how can i convert a Person Lead to Person Account and Business Lead to Business Lead. (I have two custom vf pages for creation of person account and business account respectively.)

When i am trying to convert a person lead into person account, following error is thrown on 'Converted Status' field(when selected as qualified).

 

Error: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Last Name]: [Last Name] (System Code)

 

Any help will be appreciated

Hi,

I am supposed to display address specific map on the detail page(visualforce page). I got the code from the following link.

 

http://phollaio.tumblr.com/post/22058038379/inline-google-maps-using-visualforce

 

This thing works fine on a standard page layout but my req. is to display map on a custom visualforce detail page.

Code is as follows

 

<apex:page standardController="Account">

<head>

<script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> 
<script type="text/javascript"> 

$(document).ready(function() {

  var myOptions = {
    zoom: 15,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    mapTypeControl: false
  }

  var map;
  var marker;

  var geocoder = new google.maps.Geocoder();
  if(IsPersonAccount==true)
  {
  var address1 = "{!account.PersonMailingStreet}, " + "{!account .PersonMailingCity}, " + "{!account .PersonMailingState}, " + "{!account .PersonMailingPostalCode}, " + "{!account .PersonMailingCountry}";
  
  ----------------------For PersonAccount------------------
	var infowindow = new google.maps.InfoWindow({
    content: "<b>{!Account.Account.First_Name__pc }</b><br><b>{!Account.Account.Last_Name__pc }</b><br>{!Account.PersonMailingStreet}<br>{!Account.PersonMailingCity}<br> {!Account.PersonMailingPostalCode}<br>{!Account.PersonMailingState}<br>{!Account.PersonMailingCountry}<br>"
  });

  geocoder.geocode( { address: address1}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK && results.length) {
      if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {

        //create map
        map = new google.maps.Map(document.getElementById("map"), myOptions);

        //center map
        map.setCenter(results[0].geometry.location);

        //create marker
        marker = new google.maps.Marker({
            position: results[0].geometry.location,
            map: map,
            title: "{!Account.Last_Name__pc}"
        });

        //add listeners
        google.maps.event.addListener(marker, 'click', function() {
          infowindow.open(map,marker);
        });
        google.maps.event.addListener(infowindow, 'closeclick', function() {
          map.setCenter(marker.getPosition()); 
        });

      }

    } else {
      $('#map').css({'height' : '15px'});
      $('#map').html("Oops! {!Account.Last_Name__pc}'s billing address could not be found, please make sure the address is correct.");
      resizeIframe();
    }
  });
  }
  else
  {
  var address = "{!account.BillingStreet}, " + "{!account .BillingCity}, " + "{!account .BillingPostalCode}, " + "{!account .BillingCountry}";
  
	
  ----------------------For Business Account-----------------
  var infowindow = new google.maps.InfoWindow({
    content: "<b>{!Account.Name}</b><br>{!Account.BillingStreet}<br>{!Account.BillingCity}, {!Account.BillingPostalCode}<br>{!Account.BillingCountry}"
  });

  geocoder.geocode( { address: address}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK && results.length) {
      if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {

        //create map
        map = new google.maps.Map(document.getElementById("map"), myOptions);

        //center map
        map.setCenter(results[0].geometry.location);

        //create marker
        marker = new google.maps.Marker({
            position: results[0].geometry.location,
            map: map,
            title: "{!Account.Name}"
        });

        //add listeners
        google.maps.event.addListener(marker, 'click', function() {
          infowindow.open(map,marker);
        });
        google.maps.event.addListener(infowindow, 'closeclick', function() {
          map.setCenter(marker.getPosition()); 
        });

      }

    } else {
      $('#map').css({'height' : '15px'});
      $('#map').html("Oops! {!Account.Name}'s billing address could not be found, please make sure the address is correct.");
      resizeIframe();
    }
  });

  function resizeIframe() {
    var me = window.name;
    if (me) {
      var iframes = parent.document.getElementsByName(me);
      if (iframes && iframes.length == 1) {
        height = document.body.offsetHeight;
        iframes[0].style.height = height + "px";
      }
    }
  }
}
});

</script>

<style>
#map {
  font-family: Arial;
  font-size:12px;
  line-height:normal !important;
  height:250px;
  background:transparent;
}
</style>

</head>

<body>
<div id="map"></div> 
</body> 
</apex:page>

 Controller

 

public with sharing class addressMapController {
    
    ApexPages.StandardController con;
    public Account account{get;set;}
    public Id accountId;
    public String getAccount() {
        return null;
    }
    public addressMapController(){
    }
    
    public addressMapController(ApexPages.StandardController controller){
     accountId = ApexPages.currentPage().getParameters().get('Id');
     List<Account> acc= new List<Account>([Select ID,RecordTypeId,RecordType.developername from Account where id=:accountId]);
     if(acc[0].RecordType.developername=='PersonAccount')
     {
    account = [select id, First_Name__pc,Last_Name__pc,Middle_Name__pc,Father_s_Name__pc,PersonBirthdate,Sex__pc,
                 Member_Type__pc,Public_Figure__pc,CASA_Balance__pc,Credit_Score_External__pc,Total_Relationship_Value_Under_various__pc,
                 Residential_status__pc,Total_Revenue__pc,Customer_Image__pc,CustomerSignature__pc,PersonMailingStreet,PersonOtherStreet,
                 PersonMailingCity,PersonOtherCity,PersonMailingState,PersonOtherState,PersonMailingPostalCode,PersonOtherPostalCode,PersonMailingCountry,
                 PersonOtherCountry,Office_Street__pc,PersonMobilePhone,Office_City__pc,PersonEmail,Office_State__pc,Nationality__pc,
                 Office_Zip__pc,Staying_Since__pc,Office_Country__pc,Place_of_Birth__pc,Interests__pc
                  from Account where id=:accountId];
                  }
     else if(acc[0].RecordType.developername=='Business_Account')
     {
     
     account = [Select BillingStreet,BillingCity,BillingState,BillingPostalCode,BillingCountry
                                  from Account where id=: accountId];
     account = [Select Name,Customer_ID__c, Date_of_Incorporation__c,Registration_No__c,Sales_Tax_Number__c,Excise_Number__c, 
                  Company_Type__c,Annual_Turnover__c,Credit_Score_Internal__c,Number_of_Employees__c,CASA_Balance__c,Total_Relationship_Value__c, 
                     Total_Revenue__c,Tax_Bracket__c,Loyalty_points_Accumulated_so_far__c,Credit_Score_External__c   from Account where id=:accountId];
     }
     System.debug('############################'+accountId);
    }
    public PageReference mapit(){
    return Page.addressmap;
    }
}

 Any help would be appreciated.

 

Thanks in advance,

Hi,

I am getting an error : Error: accCont Compile Error: Initial term of field expression must be a concrete SObject: LIST<Branch__c> at line 52 column 21

 

My Controller is as follows

public with sharing class accCont {
    Public Account acc{get;set;}
    ApexPages.StandardController con;
    public List<Branch__c> branch;
    
     

    public accCont(ApexPages.StandardController controller) {
    con = controller;
    this.acc = (Account) controller.getRecord();
    branch= new List<Branch__c>();
    }
    public pagereference redirect(){    
    con.save();  
    Account a = (Account) con.getRecord();
    a.recordtypeid='012f00000004Jfk';
    a.LastName = a.Last_Name__pc;
        a.FirstName = a.First_Name__pc;
        insert a;
    pagereference ref= new pagereference('/apex/personaccpage');    
    ref.setredirect(true);    
    return ref;            
    }
    public pagereference save(){
        Account a = (Account) con.getRecord();
        a.recordtypeid='012f00000004Jfk';
        a.LastName = a.Last_Name__pc;
        a.FirstName = a.First_Name__pc;
        insert a;
        String id = ApexPages.CurrentPage().getparameters().get('id');
        //return new pagereference('/apex/customerdetail?id='+a.id);
        PageReference acctPage = new PageReference('/apex/customerdetail'+'?id='+a.id);
        acctPage.setRedirect(true);
        return acctPage;
    }
    
     Public pagereference AccView() 
    {
       acc=new Account();
       insert acc;
       PageReference accview =new pagereference('/'+acc.id);
       accview.setRedirect(true);
       return accview;
    }
    
    public void fetchRecords()
    {
        //system.debug('****b.Branch_ID__pc****'+b.BranchName__pc);
        branch= [Select BranchId__c from Branch__c where id=: acc.Branch__pc];
        
        if(acc.size()>0){
                    branch.BranchId__c = acc[0].BranchId__pc;
    

    }
    }
}

 Pleae help me with this. Any help will be appreciated

Hi friends,

 

I am unable to save a record with the following code. Please help

 

-------------Controller------------------

public with sharing class personAccController {
ApexPages.StandardController con;

public personAccController(ApexPages.StandardController controller) {
con = controller;
}
public pagereference redirect(){
con.save();
pagereference ref= new pagereference('/apex/personaccpage');
ref.setredirect(true);
return ref;
}


}

 

---------------part of page----------------

<apex:pageBlockButtons >
            <apex:commandButton value="Save" action="{!save}"/>
            <apex:commandButton value="Save&New" action="{!redirect}"  />
            <apex:commandButton value="Cancel" action="{!Cancel}"/>
        </apex:pageBlockButtons>

 

Hi,

I am using person account. I am trying to differentiate person account and business account by using auto number, Person account will have auto number as APP-0001 and business account will have BA-0001.

Can anyone give a good solution for this in the form of a trigger or any other solution is greatly appreciated.