function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Kathir DevanKathir Devan 

How can i save email field in custom object

Hi,

I have created custom  field that is email in Custom object. I need to display email field in custom object A when i save the button.Code is working fine but email field not saved in Custom object .Why this happening.could you give any suggestion thanks in advance.

My VF code:
<apex:page Controller="kathir">
<apex:form >
    <apex:pageBlock title="Universal Containers">
      
            <apex:outputLabel value="Email Address" for="hh"/>
            <apex:inputText value="{!Email}" id="hh"/>
            <apex:commandButton value="save" action="{!save}"/>
      
</apex:pageBlock>
    </apex:form>
</apex:page>

Controller:
public class kathir{    public PageReference save() {        return null;    }    public String email{ get; set; }    public String getAccount() {        return null;    }    public String account { get; set; }public string Name{get;set;}{}public string Information{get;set;}{}}
subra_SFDCsubra_SFDC
try like this......


public class MyController {

private customobject__ c A;
 
public customobject__ c getOpp(){
    if(A== null)
    A=new customobject__ c();
    return A;
    }


    public PageReference save() {
        insert A;
        return null;
    }
}


<apex:page controller="myController" tabStyle="Account">
    <apex:form>

<apex:pageblock>
<apex:pageblockbutton>
<apex:commandButton action="{!save}" value="save"/>
<apex:pageblocksection>

            You belong to Account Name: <apex:inputField value="{!A.Email}"/>
</apex:pageblocksection>
</apex:pageblockbutton>
        </apex:pageBlock>

    </apex:form>
</apex:page>
Kathir DevanKathir Devan
Hi subra thanku for response, I resolve this problem. here attach my code.

VF:

<apex:page Controller="kathir">
<apex:form >
    <apex:pageBlock title="Universal Containers">
        <!--<apex:pageBlockTable value="{!account.Contacts}" var="item">-->
            <apex:outputLabel value="Email Address" for="hh"/>
            <apex:inputText value="{!Email}" id="hh"/>
            <apex:commandButton value="save" action="{!save}"/>
       <!--</apex:pageBlockTable> -->
</apex:pageBlock>
    </apex:form>
</apex:page>

Controller:

public class kathir
{

public String email1 { get; set; }
public String email{ get; set; }
public PageReference save() { 
  
MyForce__A__c emailupdate=new MyForce__A__c();
emailupdate.Name='test';

emailupdate.MyForce__email__c=email;

insert emailupdate;
        return null;
    }
}

Regards,
kathir