0

I have the following code in the CommunitiesSelfReg page

<apex:outputLabel style="font-weight:bold;" value="First Name: " for="firstName"/>
                      <apex:outputLabel id="firstNameDisplay" value="{!firstName}"  />
                      <apex:outputLabel style="font-weight:bold;" value="Last Name: " for="lastName"/>
                      <apex:outputLabel id="lastNameDisplay" value="{!lastName}" />
                      <apex:outputLabel style="font-weight:bold;" value="Email: " for="email"/>
                      <apex:outputLabel id="emailDisplay" value="{!email}" />

<apex:inputHidden id="firstName" value="{!firstName}"   />
                <apex:inputHidden id="lastName" value="{!lastName}"  />
                <apex:inputHidden id="email" value="{!email}" />
               <apex:inputHidden id="contactId" value="{!contactId}"    />


 Visualforce.remoting.Manager.invokeAction(
            '{!$RemoteAction.CommunitiesSelfRegController.getContactInfo}',
            contactId, 
            function(result, event){
                if (event.status) {
                    if (result != null){
                        jQuery("[id$=firstName]").attr("value", result.FirstName );  
                        jQuery("[id$=lastName]").attr("value", result.LastName  );  
                        jQuery("[id$=email]").attr("value", result.Email  );  
                        jQuery("[id$=communityNickname]").attr("value", result.Email  ); 

var sContactId = jQuery("[id$=contactId]").attr("value"); 
    var sPubId= jQuery("[id$=pubId]").attr("value");
    if (sContactId !=''){
        getRemoteContact(sContactId);
else {
        // cannot find the reference to contact. display error message, disable submit button
        ***jQuery("#responseErrors").html("Sorry, Invalid Contact ID"+sPubId);*** 

In the controller

public string firstName{
        get {
            if (pfirstName == null){
                pfirstName = '';
            } 
            return pfirstName;
        }
        set { 
            pfirstName = value;
        }   
    }

    private string plastName = null;
    public string lastName{
        get {
            if (plastName == null){
                plastName = '';
            } 
            return plastName;
        }
        set { 
            plastName = value;
        }   
    }
    private string pEmail = null;
    public string Email{
        get {
            if (pEmail == null){
                pEmail = '';
            } 
            return pEmail;
        }
        set { 
            pEmail = value;
        }   

    @RemoteAction
    global static Contact getContactInfo(String contactId) {
        Contact result = [SELECT Id, Name, FirstName, LastName, Phone, Email, MailingCity, MailingStreet, MailingState, MailingCountry, MailingPostalCode 
                   FROM Contact WHERE id = :contactId];
        return result;
    }

The controller class method which redirects to the CommunitiesSelfReg page is this

Public Pagereference RegisterA(){
    PageReference page = new pagereference('/apex/CommunitiesSelfReg?'+'&ContactId='+ContactId+'&Id='+pId+'%26sfdc.tabName%3C01ri00000004OyY%26submenu%3DPlan%26tile%3DPub%2BDetails');

    return page;
}

This is showing to an error

Sorry, Invalid Contact ID

.It is not printing the value of sPubId. Can someone tell me where am I making the mistake? Its really urgent

0

Change this line

var sContactId = jQuery("[id$=contactId]").attr("value");

into this

var sContactId = jQuery("[id$=contactId]").val();
  • Its still not working @tusharsharma – Rimii Jan 18 '16 at 5:44
  • @Rimii check if you are getting ID in inputhidden. – Tushar Sharma Jan 18 '16 at 9:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.