• Dorababu
  • NEWBIE
  • 25 Points
  • Member since 2013

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

I want to display Javascript alert when changes made in one tab are not saved and user moves to next tab. I am using the following code but nothing is displayed when i checked condition for language. Without this condition alert is displayed when user moves from one tab to another.

 

 

<scripttype="text/javascript" src="/soap/ajax/27.0/connection.js"></script>
<script type="text/javascript" >
var sid = getCookie('sid');
var server = "https://" + window.location.host + "/services/Soap/u/27.0";
  //initiate the connection
sforce.connection.init(sid, server);

var currentUser = sforce.connection.getUserInfo();
var result = sforce.connection.query('select LanguageLocaleKey from User where      id=\''+currentUser.getUserId+'\'');
var tab1 = document.getElementById('PPage:T1');
var tab2 = document.getElementById('PPage:T2');
var tab3 = document.getElementById('PPage:T3');
var tab4 = document.getElementById('PPage:T4');
var tab5 = document.getElementById('corpgridphone');
//alert('tabs '+tab1 +tab2 +tab3 +tab4);
var save1 = document.getElementsByName("inlineEditSave");
var cancel1 = document.getElementsByName("inlineEditCancel");
var edit2 = document.getElementById('PPage:ActformId:Actpg:Actpgb:EditButton');
var edit3 = document.getElementById('PPage:IntformId:Intpg:Intpgb:EditButton1');
var edit4 = document.getElementById('PPage:CLIformId:CLIpg:CLIpgb:EditButton2');
//alert('Edit Buttons '+edit2 +edit3 +edit4);
tab1.onclick = function() {
    if(edit2.style.display == 'none'){
    if(result == 'fr')
            {
                alert('S'il vous pla&#236;t enregistrer les modifications dans l'onglet D&#233;tails');
            }
            else if(result == 'en_US')
            {
            alert('Please save the changes in Accounts tab');}
            return false;
    }   
    if(edit3.style.display == 'none'){
    if(result == 'fr')
            {
                alert('S'il vous pla&#236;t enregistrer les modifications dans l'onglet D&#233;tails');
            }
            else if(result == 'en_US')
            {
            alert('Please save the changes in Interests tab');}
            return false;
    }
    if(edit4.style.display == 'none'){
    if(result == 'fr')
            {
                alert('S'il vous pla&#236;t enregistrer les modifications dans l'onglet D&#233;tails');
            }
            else if(result == 'en_US')
            {
            alert('Please save the changes in Client Information tab');}
            return false;
    }

}
tab2.onclick = function() {
    if(save1[0].style.display == 'inline'){
    if(result == 'fr')
            {
                alert('S'il vous pla&#236;t enregistrer les modifications dans l'onglet D&#233;tails');
            }
            else if(result == 'en_US')
            {
            alert('Please save the changes in Details tab');}
            return false;
    }       
    if(edit3.style.display == 'none'){
    if(result == 'fr')
            {
                alert('S'il vous pla&#236;t enregistrer les modifications dans l'onglet D&#233;tails');
            }
            else if(result == 'en_US')
            {
            alert('Please save the changes in Interests tab');}
            return false;
    }       

    if(edit4.style.display == 'none'){
    if(result == 'fr')
            {
                alert('S'il vous pla&#236;t enregistrer les modifications dans l'onglet D&#233;tails');
            }
            else if(result == 'en_US')
            {
            alert('Please save the changes in Client Information tab');}
            return false;
    }

}

 Any help will be greatly appreciated

 

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 a look up relation between two objects. Records of object A are added as members in Record of object B. When i try to delete the record in object B I am taken to standard deletion page. I have to modify the Heading in this standard page. In which view should i make changes so that user can see the modified Heading. Also the deletion page should show the Member names associated with object B. Now when I delete the record in object B i am getting message as

 

"Your attempt to delete the Object B record couldnot be done because it  is associated with the following Members. If the following table is empty it's because you dont have access to the records restricting the delete"

 

In the Table, Object B name is getting displayed with as many times as many member records associated with Object B(If there are 4 member records associated with record in object B, record name of Object B is displayed 4 times).

I want to display Member names instead of Object B record name. 

 

Hi,

I am using the following script to show many years in date picker. I have tabs in my vf page, when I use this code I am unable to switch between tabs. With out the script I was able to switch to other tabs. Any help to switch to others tab with the date picker code working fine wuld be appreciated.

 

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<span id="hideThisHomePageComp"></span>
<script type="text/javascript">
$j = jQuery.noConflict();
$j(document).ready(function() {
                var startYear=1985;
                var endYear=2024;
                var htmlStr='';
                if(startYear<endYear){
                                for(i=startYear;i<endYear+1;i++){
                                                htmlStr += "<option value=\""+i+"\">"+i+"</option>";
                                }
                                $j('#calYearPicker').html(htmlStr);
                }
                $j('#sidebarDiv #hideThisHomePageComp').parent().parent().hide();
                }
);
</script>

 

I have a field Primary Phone Identifier(Picklist:Phone 1/Phone2/Phone3)field  on Account.  HouseholdMember is a child of Account and Group. I wrote a trigger for a member who is primary in household member, his email which is selected in Primary Phone Identifier(say Phone 1), phone 1 value in Account is cascaded to Group level. Now,  if Primary Phone Identifier is changed to Phone 2 this is updated at Household Member but I am unable to cascade it to Group object. Help me in updating it  to Group object.

 

The trigger is as follows.

 

trigger PopulatePhoneEmail on Household_Member__c (after insert,after update) 
{
Set<ID> householdgroupids=new Set<ID>();
Set<ID> Accountids=new Set<ID>();
List<Household_Group__c> hhglist = new List<Household_Group__c>();
list<Household_Group__c> householdgroupuplist=new list<Household_Group__c>();
List<Household_Member__c> memlist = new List<Household_Member__c>();
List<Household_Member__c> memupdatelist = new List<Household_Member__c>();
Integer count;
boolean isListUpdated;

hhglist = [Select id,Status__c,Name FROM Household_Group__c WHERE id in:householdgroupids];

for(Household_Member__c hm:trigger.new)
{
householdgroupids.add(hm.Household_Group__c);
Accountids.add(hm.Member__c);
}
map<id,Household_Group__c> householdgroupmap = new map<id,Household_Group__c>([SELECT Id,Email__c,primary_city__c,Primary_Phone__c from Household_Group__c where id in:householdgroupids]);
map<Id,Account> accids = new map<Id,Account>([Select id,BillingStreet,BillingCity,BillingState,BillingPostalCode,BillingCountry FROM Account WHERE id IN:Accountids]); 
for(Household_Member__c hm:trigger.new)
{
if(hm.Primary__c == true)
{
Household_Group__c hg=new Household_Group__c();
Account acc=new Account();
acc=accids.get(hm.member__c);
hg=householdgroupmap.get(hm.Household_Group__c);
if(hg!=null )
{
hg.Primary_Phone__c = hm.Primary_Phone__c;
hg.Primary_street__c = acc.BillingStreet;
hg.Primary_street__c = acc.BillingStreet;
hg.primary_city__c = acc.BillingCity;
hg.primary_province__c = acc.BillingState;
hg.primary_postal_code__c= acc.BillingPostalCode;
hg.primary_country__c = acc.BillingCountry;
hg.Email__c = hm.Email__c;
householdgroupuplist.add(hg);
}
}
}
if(!householdgroupuplist.isempty())
{
try
{
update householdgroupuplist;
}
catch(Exception e)
{
System.debug(e);
}
}

}

 

hi friends,

I came to know that sandbox instances can be created for developer org. I've tried a lot nd dint find anyway to setup sandbox. 

please help me with the procedure to setup free sandbox instance.

Hi,

I have a field Primary Phone which is a picklist. I have phone 1, phone 2,3,4 in master object. I should update a field in child such that if Primary Phone is selected as phone 1, value should be prepopulated in child's field, if selected t phone 2, value in child object's field is phone 2 and so on. 

I have tried the following and there were no errors and save was successful. But primary phone field(which is child field) is not getting any value.

 

-------  Using IF -----------

 

IF(ISPICKVAL( Household_Name__r.Primary_Phone_Identifier__c,"Phone 1" ),Household_Name__r.Phone,
IF(ISPICKVAL( Household_Name__r.Primary_Phone_Identifier__c,"Phone 2" ),Household_Name__r.Phone_2__c,
IF(ISPICKVAL( Household_Name__r.Primary_Phone_Identifier__c,"Phone 3" ),Household_Name__r.Phone_3__c,
IF(ISPICKVAL( Household_Name__r.Primary_Phone_Identifier__c,"Phone 4" ),Household_Name__r.Phone_4__c,NULL)))
)

-------------------------------------------

 

------------- Using Case ---------------------------

CASE(ISPICKVAL( Household_Name__r.Primary_Phone_Identifier__c,"Phone 1" ) , Phone 1, Household_Name__r.Phone ,
ISPICKVAL( Household_Name__r.Primary_Phone_Identifier__c,"Phone 2" ) , Phone 2, Household_Name__r.Phone_2__c ,
ISPICKVAL( Household_Name__r.Primary_Phone_Identifier__c,"Phone 3" ) , Phone 3, Household_Name__r.Phone_3__c ,
ISPICKVAL( Household_Name__r.Primary_Phone_Identifier__c,"Phone 4" ) , Phone 4, Household_Name__r.Phone_4__c ,
NULL)

-------------------------------------------------------------------

 

Help me with IF condition. Is it valid to write a ISPICKVAL on parent's field in child object's field?

Any help will be appreciated.

 

 

Hi,

I am new to triggers. I wanted to assign FirstName and LastName to customFields, which I have tried as follows.

PLease improve the code. Any help will be appreciated.

 

trigger copyFirstNameLastName on Account (before insert) {
    for(Account ac:trigger.new){
    List<Account> acc = new List<Account>([Select id,FirstName,LastName from Account Where id IN :Trigger.new]); 
                     
    for(Account a:acc){
    if(acc.IsPersonAccount==true){
        if(!acc.isEmpty()){
        acc.First_Name__pc = acc.FirstName;
        acc.Last_Name__pc = acc.LastName;
        }
        }
    update acc;
    }
    }
    
}

 -- Thanks in Advance --

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,

Loyalty points field should be updated when a primary account's relation's balance changes. Suppose personA is primary account and personB is peraonA's relation. If personB's balance changes, personA loyalty points should be dynamically changed. Relaton between paersonA and personB is stored in object FamilyBanking__c.

Can this be achieved through trigger?  Any help will be greatly appreciated.

 

-- Thanks in Advance --

Hi,

I have developed visualforce pages and noticed that when navigated to those pages after saving a record, the URL is not delivering the secure form. I mean to say that it is not https and it is https in red color with a cross line over it. Does this compromise any security related issues?

How can I make it https in green color.

 

Thanks in Advance,

 

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 Friends,

I am working on person accounts.

For detail page of Accounts I have two custom VF pages. I have opportunity as a related list on detail page of Person account. When i click the 'new opportunity'  button on the related list I am redirected to Opportunity creation page(also a custom VF page). Here, on Opportunity creation page, Account name is auto populated while contact name is not. In case of person Acc. as acc. name and contact name are same, the contact name should also be autopopulated. How can I achieve this? How can i write java script code for the button on (opportunity)related list of Account, which is a standard button.


Please help me with any good solution.

 

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 trying to autopopulate Document ID Number based on Document ID which is a look up to KYC__c object.

Primarily my problem is I should be able to insert one more dynamically onclicking a hyper link. I have tried the following page

 

---------------------apex page ------------------------

<apex:page standardController="Opportunity">

<apex:sectionHeader title="Opportunity Edit" subtitle="New Opportunity"/>
<apex:form >
<apex:pageBlock title="Opportunity Edit">
<apex:pageMessages />
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Save & New" action="{!save}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Opportunity Information" columns="2">
<apex:outputLabel > <b> Opportunity Owner </b><l> {!$User.FirstName} {!$User.LastName}</l></apex:outputLabel>
<apex:inputField value="{!opportunity.leadsource}"/>
<apex:inputField value="{!opportunity.name}"/>

<apex:inputField value="{!opportunity.CloseDate}"/>
<apex:inputField value="{!opportunity.AccountId}" required="true"/>
<apex:inputField value="{!opportunity.StageName}"/>
<apex:inputField value="{!opportunity.Contact__c}"/>
<apex:inputField value="{!opportunity.Probability}" required="false" />
<apex:inputField value="{!opportunity.CampaignId}"/>
<apex:inputField value="{!opportunity.Amount}"/>
<apex:inputField value="{!opportunity.Type}"/>
<apex:inputField value="{!opportunity.Competitors__c}"/>
<!-- <apex:inputField value="{!opportunity.ID_Proof__c}"/>-->

<apex:inputField value="{!opportunity.ID_Proof__c}" required="true" style="width:150px"/>

<apex:inputField value="{!opportunity.Document_ID_Number__c}"/>


<apex:actionRegion >
<apex:commandLink style="font-weight:bold; padding-right:15px" >
Insert another row for adding another Document
</apex:commandLink>

<apex:actionSupport event="oncclick" reRender="addrow"/>
</apex:actionRegion>
<apex:outputpanel id="addrow" rendered="{!if(opportunity.ID_Proof__c !=NULL,true,false)}">

<apex:inputField value="{!opportunity.ID_Proof__c}" required="true" style="width:150px"/>

<apex:inputField value="{!opportunity.Document_ID_Number__c}"/>
</apex:outputpanel>



</apex:pageBlockSection>
<apex:pageBlockSection title="Description Information" columns="2">
<apex:inputField value="{!opportunity.description}" style="width: 400px; height: 100px"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

---------------------------------------------------------------------------

I am enable to insert a row an clicking hyperlink. 

For controller I am unable to code. Requirement is Account Name and Opportunity is autopopulated. Query shoul be like it shoud fetch the Document ID Number from KYC__c object upon selecting the Document ID type in look up in opportunity page. (opportunity is having a look up relation with KYC__c ). Please help me this is urgent.

hi,

Can anyone tell me if the contact name on detail page is saved as a field set?

My requirement is to save FirstName and LastName separately not as salesforce saves by default(title,firstname,lastname all put together). Is it possible to split and extract the FirstName and LastName through apex coding as i have to perform search of a contact(person account) based on FirstName or LastName.

 

Any help will be appreciated

 

 

Hi friends,

In my sandbox we have enabled Person Accounts. The problem is when a record is saved it should go to different custom detail pages based on person account or business account. I have tried overriding the View button and this is redirecting even the business account to the overriden page(which is for personAccount detail page). If a record is being saved it shuld be redirected, to person account detail page if account is person acccount and, to business account detail page if account is BusinessAccount. 

 

For save in businessAccount creation page controller:

public PageReference saveRedirect(){

Account a = (Account) con.getRecord();
insert a;
return new pagereference('https://c.cs16.visual.force.com/apex/CustomerBusinessDetail'+a.id);
}

 

---------------------

for save in personAccount controller:

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;
return new pagereference('/'+a.id);
}

 

 

Where should I differentiate the saving criteria?

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 friends,

In my app I have renamed standard Account tab to customer. After this custom object with name as Customer is created(which is part of other app). Now accidentally I have reset the standard Account object to defaults. When i tried renaming the account tab to Customer I got error as "duplicate value, a custom object already exist". Will this effect the Api names, how can I rename the account tab again to customer?

Please suggest a good solution to overcome this problem as renaming account as customer is mandatory.

Hi friends,


I have query regarding relationship between objects. I have One standard object(A), two custom objects(B,C). I want C as related list in both A and B. What kind of relationship should be there between A,B and C(I think look up does it). But I want A and B as related lists in C also. To serve this purpose what kind of relation should be there?

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.