I have a Visualforce Page which creates an Account based on data given by user, such as Name, Phone, and other details. I would like to include state and country too. I am using

<apex:inputfield value ="{!customobject__c.account__r.billingcountrycode}">

This tag displays the country picklist on the page. When I select a value and save it, the Account is created but the country value is not saved. How can I fix it?

  • 1
    can you please share your code which is not working
    – sf_user
    Jul 6, 2016 at 18:23
  • 1
    please post your code of vf page and controller(if any). For your case you might have to have a controller that takes the user entered value on page and insert an account with country.
    – Anurag
    Jul 6, 2016 at 19:17
  • looks like you are using State and Country picklists. Is the value in {!customobject__c.account__r.billingcountrycode} defined as the integration value for Countries?
    – cropredy
    Dec 22, 2016 at 2:43

2 Answers 2


Based on my understanding I tried to replicate your issue and its working fine for me. Please check the VF page and controller below.

VF page

<apex:page controller="Cntl_VfPage" >
        <apex:inputText value="{!name}"/>

        <apex:inputfield value ="{!a.Billingcountrycode__c}" ></apex:inputfield>

        <apex:commandButton value="Submit" action="{!submit}"/>


public class Cntl_VfPage {
    public String name {set; get;}
    public Account a {set; get;}

    public Cntl_VfPage() {
        a = new Account();

    public PageReference submit() {
        a.Name = name;
        // system.debug(a.name + ' | ' + a.Billingcountrycode__c);
        insert a;
        PageReference pageRef = new PageReference('/' + a.Id);
        return pageRef;         

enter image description here


Instead of "{!customobject__c.account__r.billingcountrycode}" Try to use "{!account.billingcountrycode}"

Of course, if you are using the standard accounts

  • No i am not using standard account.
    – Radha d
    Jul 6, 2016 at 21:25
  • If you don't want to use a controller, you should work directly with the object and use standardController='yourObject' Because now you are editing the lookup of the object Jul 7, 2016 at 7:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .