• DeepV
  • NEWBIE
  • 95 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 15
    Questions
  • 27
    Replies
Hi,

I'm new to coding and writing test classes:

Here is my class method :
There is an existiving test class. I need to do code coverage for the below method

  public boolean addProposedLegalNameb(){
     
      Date dtToday = Date.today();
     
        if(anewSubmission.REL_VS_ProposedLegalNameChange__c == null || anewSubmission.REL_VS_ProposedLegalNameChange__c == ''){
           ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Please enter the Proposed Legal Name.')); 
           return false;
       }
       if(anewSubmission.REL_VS_LegalNameChangeReason__c == null || anewSubmission.REL_VS_LegalNameChangeReason__c == ''){
           ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Please enter the Reason for Name Change.')); 
           return false;
       }
       if(anewSubmission.REL_VS_LegalNameChangeDate__c > dtToday){
           ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Please DO NOT enter the future Date.')); 
          return false;
       }
       
        REL_VS_Submission__c obj = [select REL_VS_ProposedLegalNameChange__c, REL_VS_LegalNameChangeReason__c, REL_VS_LegalNameChangeDate__c, REL_VS_ConfirmLegalNameChange__c  from REL_VS_Submission__c where id = :anewSubmission.Id];            
        obj.REL_VS_ProposedLegalNameChange__c =  anewSubmission.REL_VS_ProposedLegalNameChange__c;
        obj.REL_VS_LegalNameChangeReason__c = anewSubmission.REL_VS_LegalNameChangeReason__c;
        obj.REL_VS_LegalNameChangeDate__c  = anewSubmission.REL_VS_LegalNameChangeDate__c; 
        obj.REL_VS_ConfirmLegalNameChange__c = 'Yes';
    
      partialSave();
           
       return true;
    }
  • June 27, 2018
  • Like
  • 0
When I click the edit button, the popup displays but does not display any data. Please help!
What is the mistake I'm doing it here.
what I have tried so far:

Visual Force:

<apex:page standardcontroller="UCF_REL__c" extensions="UCFController" sidebar="false" > 
<apex:sectionheader title="UCF Review" /> 
<apex:messages />
 <apex:form rendered="{!displaySection}"> 
<script type="text/javascript"> function LegalNameChangePopup(){ var newwindow = window.open('RELLegalNameChangePopup', 'name=_blank','height=500,width=500,left=250,top=100'); newwindow.focus(); } 
</script>
 <apex:pageblock title="General Information" > 
<apex:pageblocksection title="Legal Name"> 
<apex:panelgrid columns="2"> 
<!-- <apex:outputlabel value="Account Name: " for="accountName" />-->
 <apex:outputfield id="accountName" value="{!aaccount.name}"/>
 <apex:commandbutton value="Edit" id="accpopup" onclick="LegalNameChangePopup();" styleclass="btn"/>
 </apex:panelgrid>
 </apex:pageblocksection> 
</apex:pageblock> 
<apex:pageblock > 
<apex:pageblocksection columns="4"> 
<apex:commandbutton action="{!step2}" value="Save and Continue" styleclass="btn" />
 <apex:commandbutton action="{!reset}" value="Reset Page" styleclass="btn" immediate="true"/>
 </apex:pageblocksection>
 </apex:pageblock> 
</apex:form>
 </apex:page>

VF for popup: RELLegalNameChangePopup

<apex:page standardcontroller="UCF_REL__c" extensions="UCFController" showheader="false" sidebar="false" id="the">
  <apex:form id="page"> 
<apex:pageBlock >
 <apex:pageBlockSection columns="1" title="Legal Name change"> 
<apex:pageblocktable value="{!aAccount}" var="item" id="editAccountName">
 <apex:column headervalue="Proposed Legal Name">
 <apex:inputtext value="{!item.Name}" />
 </apex:column> </apex:pageblocktable>
 </apex:pageBlockSection> 
</apex:pageBlock>
 </apex:form>
  • June 05, 2018
  • Like
  • 0
Onclick of the button on vf page. How can I get the input field lookup value.
I have a lookup value A,B,C. based on the condition, say lookup == "A" then I want to enable or disable the inputfield.
Can I achieve this from javascript?
TIA
  • June 05, 2018
  • Like
  • 0
Hi all,
 I have the inputfield inside the pageblocktable, when the page is display the Role should be readonly.

When the user clicks the button i'e; onclick I want the role field to be editable. How can I do this?

NOTE: each time the user clicks the  Add Contact button then the field should be editable.

  <apex:pageblocksection title="Contact Information" columns="1">
                <apex:pageblocktable value="{!anewContact}" var="item" id="newContactitems"  columnsWidth="5%,20%,10%,10%,10%,10%,5%,5%,5%,5%,10%,3%,2%">
                    <!-- A button to remove individual entry. s
                    We must to pass the line number to define a list entry number to remove -->
                    <apex:column headervalue="Delete">
                        <apex:commandbutton immediate="true" action="{!removeContactObject}" value=" X " rerender="newContactitems,panelWithVar">
                            <apex:param name="p2" value="{!rowContactNumber}" assignto="{!numberOfContactRowToRemove}" />
                        </apex:commandbutton>
                    </apex:column>
                    <!-- Moreover here we incrementing the row number variable -->
                    <!--<apex:column headerValue="RowCount">
                        <apex:outputText value="{!rowContactNumber}"/>
                    </apex:column>-->
                   <apex:column headervalue="Role">
                        <apex:inputfield value="{!item.REL_VS_Contact_Role__c}" html-disabled="{!editMode}"/>
                        <apex:variable var="rowContactNumber" value="{!rowContactNumber + 1}" />
                    </apex:column>
 </apex:pageblocktable>
 
  • June 04, 2018
  • Like
  • 0
Hi All,

I have the following visualforce page, initially when the page loads the Role Field should be readonly. But when AddContact button is clicked then the Role field should be editable. 

<apex:page standardcontroller="REL_VS_Submission__c" extensions="RELVSRenewalController" sidebar="false">
    <apex:sectionheader title="VSA Renewal Submission" subtitle="Step 2 of 10" />
    <apex:messages />
    <apex:form >
        <apex:pageblock title="Contact Information">
<apex:variable value="{!0}" var="rowContactNumber" />
            <!-- Here we will use an extra variable to define a row number -->
            <apex:outputpanel id="panelWithVar">
                <apex:variable value="{!0}" var="rowContactNumber" />
            </apex:outputpanel>
            <apex:pageblocksection title="Contact Information" columns="1">
                <apex:pageblocktable value="{!anewContact}" var="item" id="newContactitems"  columnsWidth="5%,20%,10%,10%,10%,10%,5%,5%,5%,5%,10%,3%,2%">
                    <!-- A button to remove individual entry. s
                    We must to pass the line number to define a list entry number to remove -->
                    <apex:column headervalue="Delete">
                        <apex:commandbutton immediate="true" action="{!removeContactObject}" value=" X " rerender="newContactitems,panelWithVar">
                            <apex:param name="p2" value="{!rowContactNumber}" assignto="{!numberOfContactRowToRemove}" />
                        </apex:commandbutton>
                    </apex:column>
                    <!-- Moreover here we incrementing the row number variable -->
                    <!--<apex:column headerValue="RowCount">
                        <apex:outputText value="{!rowContactNumber}"/>
                    </apex:column>-->
                  
                    <apex:column headervalue="Role">
                        <apex:inputfield value="{!item.REL_VS_Contact_Role__c}" disabled="{!isDisabled"/>
                        <apex:variable var="rowContactNumber" value="{!rowContactNumber + 1}" />
                    </apex:column>
                    <apex:column headervalue="First Name">
                        <apex:inputfield value="{!item.Firstname}" required="true" />
                    </apex:column>
                    <apex:column headervalue="Last Name">
                        <apex:inputfield value="{!item.Lastname}" required="true" />
                    </apex:column>
                    <apex:column headervalue="Phone">
                        <apex:inputfield value="{!item.Phone}" required="true" />
                    </apex:column>
                    <apex:column headervalue="Fax">
                        <apex:inputfield value="{!item.Fax}" required="true" />
                    </apex:column>                  
                    <apex:column headervalue="Personal Email">
                        <apex:inputfield value="{!item.Email}" required="true" />
                    </apex:column>
                    <apex:column headervalue="General Email" >
                        <apex:inputfield value="{!item.REL_VS_Generic_Email__c}" />
                    </apex:column>
                    <apex:column headervalue="Title">
                        <apex:inputfield value="{!item.Title}" required="true"/>
                    </apex:column>
                     <apex:column headervalue="Mailing Street">
                        <apex:inputfield value="{!item.MailingStreet}" required="true"/>
                    </apex:column>
                    <apex:column headervalue="Mailing City">
                        <apex:inputfield value="{!item.MailingCity}" required="true"/>
                    </apex:column>
                    <apex:column headervalue="Mailing State">
                        <apex:inputfield value="{!item.MailingState}" required="true" />
                    </apex:column>
                    <apex:column headervalue="Mailing Zip">
                    <apex:inputfield value="{!item.MailingPostalCode}" required="true" />
                    </apex:column>
                 </apex:pageblocktable>
            </apex:pageblocksection>
            <!-- A main button to add a new item -->
            <apex:commandbutton value="Add Contact" action="{!addContactObject}" rerender="newContactitems,panelWithVar" immediate="true"/>

        </apex:pageblock>
        <apex:pageblock >
            <apex:pageblocksection columns="4">
                <apex:commandbutton action="{!step3}" value="Save and Continue"
                                    styleclass="btn" />
                <apex:commandbutton action="{!reset}" value="Reset Page"
                                    styleclass="btn" immediate="true" />
                <apex:commandbutton action="{!exit}" value="Exit"
                                    styleclass="btn" immediate="true" />
                <apex:commandbutton action="{!Back}" value="Back"
                                    styleclass="btn" immediate="true" />
            </apex:pageblocksection>
        </apex:pageblock>
    </apex:form>
</apex:page>

Apex code:
 public Boolean isDisabled {get; set;}
//constructor
 isDisabled = true;

 public PageReference addContactObject() {
        anewContact.add(new Contact(FirstName = ''));
//making it editable     
  isDisabled = false;
        return null;
    }

Please help me, the above code is failing for me.
  • June 04, 2018
  • Like
  • 0
I have REL_VS_Contact_Role__c field which is read only when the page loads. But when I click on the add new button(addContactObject). I wanted it to be editable, how do i achieve this?

Visualforce :

<apex:page standardcontroller="REL_VS_Submission__c" extensions="RELVSRenewalController" sidebar="false">
    <apex:sectionheader title="VSA Renewal Submission" subtitle="Step 2 of 10" />
    <apex:messages />
    <apex:form >
        <apex:pageblock title="Contact Information">
            Video providers must submit contact information for <b>at least 3 persons</b>: 1) the person authorized to receive information regarding the VSA; 2) the person designated to receive subscriber complaints and 3) the person designated to receive information regarding the annual cable assessment. If the data listed below is correct and complete, select save and continue. If any portion of the data is incorrect or missing, make the corrections now, then select save and continue.
            <!-- This facet tag defines the "Next" button that appears
            in the footer of the pageBlock. It calls the step2()
            controller method, which returns a pageReference to
            the next step of the wizard. -->
            <!--<apex:facet name="footer">
                <apex:commandbutton action="{!step3}" value="Save and Continue"
                                    styleclass="btn" />
            </apex:facet>-->
            <apex:variable value="{!0}" var="rowContactNumber" />
            <!-- Here we will use an extra variable to define a row number -->
            <apex:outputpanel id="panelWithVar">
                <apex:variable value="{!0}" var="rowContactNumber" />
            </apex:outputpanel>
            <apex:pageblocksection title="Contact Information" columns="1">
                <apex:pageblocktable value="{!anewContact}" var="item" id="newContactitems"  columnsWidth="5%,20%,10%,10%,10%,10%,5%,5%,5%,5%,10%,3%,2%">
                    <!-- A button to remove individual entry. s
                    We must to pass the line number to define a list entry number to remove -->
                    <apex:column headervalue="Delete">
                        <apex:commandbutton immediate="true" action="{!removeContactObject}" value=" X " rerender="newContactitems,panelWithVar">
                            <apex:param name="p2" value="{!rowContactNumber}" assignto="{!numberOfContactRowToRemove}" />
                        </apex:commandbutton>
                    </apex:column>
                    <!-- Moreover here we incrementing the row number variable -->
                    <!--<apex:column headerValue="RowCount">
                        <apex:outputText value="{!rowContactNumber}"/>
                    </apex:column>-->
                  
                   <apex:column headervalue="Role">
                        <apex:inputfield value="{!item.REL_VS_Contact_Role__c}" html-disabled="true"/>
                        <apex:variable var="rowContactNumber" value="{!rowContactNumber + 1}" />
                    </apex:column>
                    <apex:column headervalue="First Name">
                        <apex:inputfield value="{!item.Firstname}" required="true" />
                    </apex:column>
                    <apex:column headervalue="Last Name">
                        <apex:inputfield value="{!item.Lastname}" required="true" />
                    </apex:column>
                    <apex:column headervalue="Phone">
                        <apex:inputfield value="{!item.Phone}" required="true" />
                    </apex:column>
                    <apex:column headervalue="Fax">
                        <apex:inputfield value="{!item.Fax}" required="true" />
                    </apex:column>                  
                    <apex:column headervalue="Personal Email">
                        <apex:inputfield value="{!item.Email}" required="true" />
                    </apex:column>
                    <apex:column headervalue="General Email" >
                        <apex:inputfield value="{!item.REL_VS_Generic_Email__c}" />
                    </apex:column>
                    <apex:column headervalue="Title">
                        <apex:inputfield value="{!item.Title}" required="true"/>
                    </apex:column>
                     <apex:column headervalue="Mailing Street">
                        <apex:inputfield value="{!item.MailingStreet}" required="true"/>
                    </apex:column>
                    <apex:column headervalue="Mailing City">
                        <apex:inputfield value="{!item.MailingCity}" required="true"/>
                    </apex:column>
                    <apex:column headervalue="Mailing State">
                        <apex:inputfield value="{!item.MailingState}" required="true" />
                    </apex:column>
                    <apex:column headervalue="Mailing Zip">
                    <apex:inputfield value="{!item.MailingPostalCode}" required="true" />
                    </apex:column>
                 </apex:pageblocktable>
            </apex:pageblocksection>
            <!-- A main button to add a new item -->
            <apex:commandbutton value="Add Contact" action="{!addContactObject}" rerender="newContactitems,panelWithVar" immediate="true"/>

        </apex:pageblock>
        <apex:pageblock >
            <apex:pageblocksection columns="4">
                <apex:commandbutton action="{!step3}" value="Save and Continue"
                                    styleclass="btn" />
                <apex:commandbutton action="{!reset}" value="Reset Page"
                                    styleclass="btn" immediate="true" />
                <apex:commandbutton action="{!exit}" value="Exit"
                                    styleclass="btn" immediate="true" />
                <apex:commandbutton action="{!Back}" value="Back"
                                    styleclass="btn" immediate="true" />
            </apex:pageblocksection>
        </apex:pageblock>
    </apex:form>
</apex:page>
  • June 01, 2018
  • Like
  • 0

Hi All,

I have the following code with pageblocktable, I have 12 columns to display which are display as one column but

I want it display as 4 columns:
Delete      Role    Firstname        Lastname
Phone      Fax     GeneralEmail  PersonalEmail
Address   City    State                 Zip

<apex:page standardcontroller="REL_VS_Submission__c" extensions="RELVSRenewalController" sidebar="false">
    <apex:sectionheader title="VSA Renewal Submission" subtitle="Step 2 of 10" />
    <apex:messages />
    <apex:form >
        <apex:pageblock title="Contact Information">
            Video providers must submit contact information for <b>at least 3 persons</b>: 1) the person authorized to receive information regarding the VSA; 2) the person designated to receive subscriber complaints and 3) the person designated to receive information regarding the annual cable assessment. If the data listed below is correct and complete, select save and continue. If any portion of the data is incorrect or missing, make the corrections now, then select save and continue.
            <!-- This facet tag defines the "Next" button that appears
            in the footer of the pageBlock. It calls the step2()
            controller method, which returns a pageReference to
            the next step of the wizard. -->
            <!--<apex:facet name="footer">
                <apex:commandbutton action="{!step3}" value="Save and Continue"
                                    styleclass="btn" />
            </apex:facet>-->
            <apex:variable value="{!0}" var="rowContactNumber" />
            <!-- Here we will use an extra variable to define a row number -->
            <apex:outputpanel id="panelWithVar">
                <apex:variable value="{!0}" var="rowContactNumber" />
            </apex:outputpanel>
            <apex:pageblocksection title="Contact Information" >
                <apex:pageblocktable value="{!anewContact}" var="item" id="newContactitems">
                    <!-- A button to remove individual entry. s
                    We must to pass the line number to define a list entry number to remove -->
                    <apex:column width="5%" headervalue="Delete">
                        <apex:commandbutton immediate="true" action="{!removeContactObject}" value=" X " rerender="newContactitems,panelWithVar">
                            <apex:param name="p2" value="{!rowContactNumber}" assignto="{!numberOfContactRowToRemove}" />
                        </apex:commandbutton>
                    </apex:column>
                    <!-- Moreover here we incrementing the row number variable -->
                    <!--<apex:column headerValue="RowCount">
                        <apex:outputText value="{!rowContactNumber}"/>
                    </apex:column>-->
                  
                   <apex:column headervalue="Role">
                        <apex:inputfield value="{!item.REL_VS_Contact_Role__c}" html-disabled="true"/>
                        <apex:variable var="rowContactNumber" value="{!rowContactNumber + 1}" />
                    </apex:column>
                    <apex:column headervalue="Firstname">
                        <apex:inputfield value="{!item.Firstname}" required="true" />
                    </apex:column>
                    <apex:column headervalue="Lastname">
                        <apex:inputfield value="{!item.Lastname}" required="true" />
                    </apex:column>
                    <apex:column headervalue="Phone">
                        <apex:inputfield value="{!item.Phone}" required="true" />
                    </apex:column>
                    <apex:column headervalue="Fax">
                        <apex:inputfield value="{!item.Fax}" required="true" />
                    </apex:column>                  
                    <apex:column headervalue="Personal Email">
                        <apex:inputfield value="{!item.Email}" required="true" />
                    </apex:column>
                    <apex:column headervalue="General Email">
                        <apex:inputfield value="{!item.REL_VS_Generic_Email__c}" />
                    </apex:column>
                    <apex:column headervalue="Title">
                        <apex:inputfield value="{!item.Title}" required="true"/>
                    </apex:column>
                     <apex:column headervalue="Mailing Street">
                        <apex:inputfield value="{!item.MailingStreet}" required="true"/>
                    </apex:column>
                    <apex:column headervalue="Mailing City">
                        <apex:inputfield value="{!item.MailingCity}" required="true"/>
                    </apex:column>
                    <apex:column headervalue="Mailing State">
                        <apex:inputfield value="{!item.MailingState}" required="true" />
                    </apex:column>
                    <apex:column headervalue="Mailing Zip">
                    <apex:inputfield value="{!item.MailingPostalCode}" required="true" />
                    </apex:column>
                 </apex:pageblocktable>
            </apex:pageblocksection>
            <!-- A main button to add a new item -->
            <apex:commandbutton value="Add Contact" action="{!addContactObject}" rerender="newContactitems,panelWithVar" immediate="true" />

        </apex:pageblock>
        <apex:pageblock >
            <apex:pageblocksection columns="4">
                <apex:commandbutton action="{!step3}" value="Save and Continue"
                                    styleclass="btn" />
                <apex:commandbutton action="{!reset}" value="Reset Page"
                                    styleclass="btn" immediate="true" />
                <apex:commandbutton action="{!exit}" value="Exit"
                                    styleclass="btn" immediate="true" />
                <apex:commandbutton action="{!Back}" value="Back"
                                    styleclass="btn" immediate="true" />
            </apex:pageblocksection>
        </apex:pageblock>
    </apex:form>
</apex:page>

Thanks
 
  • May 30, 2018
  • Like
  • 0
Sending an email from a process builder when a condition is true. My business users want to save the email as PDF.

How can I achieve this?

TIA
  • May 15, 2017
  • Like
  • 0
Hi Friends,

I have a table (Detail) in SQL and creating a custom object in Salesforce (Detail__c). 
Below are the fields in SQL Detail Table:
User-added image

WIll they be a picklist? But how can I relate Detail_Acc_no, Description, TYpe and Detail_account_class all in one picklist? How can this be structured?


TIA

 
  • May 10, 2017
  • Like
  • 0
Why is the label twice? I have a email__c field and trying to validate using apex on visualforce page. 
  • April 24, 2017
  • Like
  • 0
Hi All,

I'm trying to show an error message near the email field on visualforce page. Can I use ouputtext and innerhtml to display message?
Here is my code:

<apex:page id="thepage" controller="mySurvey">pt>
    <script type="text/javascript">
        var examNote = document.getElementsByClassName('examNote')[0].value;
        var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/i;
        var validEmail = re.test(examNote);
             if(validEmail == false) {
             alert("email not valid"); //checking if the code is reaching here by an alert message
             //code to show the error message on vf page instead of alert
            
     </script>
    <apex:form id="audit">
        <apex:pageblock id="pb1" >
          <apex:pageblockSection id="pbs1" columns="1">
            <p><apex:inputText value="{!account}" label="Account"/></p>
            <apex:inputText id="Survey" value="{!txtSurvey}" label="SurveyName"/>
            <apex:inputText id="examNote" value="{!examNote}" Label="Exam Note" styleClass="examNote"/>
            <apex:outputText value="{0}">
                <apex:param value="result"/>
            </apex:outputText>
              <apex:commandButton action="{!save}" onclick="return validate();" value="save"/>
          </apex:pageblockSection>
        </apex:pageblock>
    </apex:form>
</apex:page>
  • April 21, 2017
  • Like
  • 0
Hi,

I'm passing accountid as id and contactid in the url.

When the users click save, I need to update a datefield__c to today(without time) on contact object.

Here is my vf page - 
<apex:page controller="myAudit">
    <apex:form >
        <apex:pageblock >
          <apex:pageblockSection columns="1">
            <p><apex:inputText value="{!account}" label="Account"/></p>
            <apex:inputText id="Survey" value="{!txtSurvey}" label="SurveyName"/>
              <apex:commandButton action="{!save}" value="save"/>
          </apex:pageblockSection>
        </apex:pageblock>
    </apex:form>
</apex:page>

My apex class:
public class myAudit {

   public myAudit() {
    account =  [SELECT Id, Name FROM Account WHERE Id = :ApexPages.currentPage().getParameters().get('id')].Name;
   }

    public String account { get; set; }

    public String txtSurvey { get; set; }

    public PageReference save() {
         Audit_Questionnaire__c aq = new Audit_Questionnaire__c();
            aq.Name = txtSurvey;
            aq.account__c = apexpages.currentpage().getparameters().get('id');
            insert aq;
            return null;
        }
}
 
  • April 17, 2017
  • Like
  • 0
Hi,

I'm trying to get the custom field (Hold_ID__c) on to Visualforce page. I am not getting the value in the page.

Passing account id in the url for the page

Here is my VF page:

<apex:page controller="Questionnaire" sidebar="false" showHeader="false">
    <apex:form >
        <apex:pageblock >
           <apex:pageBlockSection columns="1">
            <apex:inputText value="{!account}" label="Hold Name"/>
            <apex:inputText value="{!holdId}" label="Hold ID"/>
            <apex:inputText id="Survey" value="{!txtSurvey}"/>
            <apex:commandButton action="{!save}" value="save"/>
           </apex:pageBlockSection>
        </apex:pageblock>
    </apex:form>
</apex:page>

Apex code:

public class Questionnaire{

    public String holdId { get; set; }

    public String txtSurvey { get; set; }

    public String account { get; set; }
    
    public Questionnaire() {
    account =  [SELECT Id, Name,Account.Hold_ID__c FROM Account WHERE Id = :ApexPages.currentPage().getParameters().get('id')].Name;
    holdId = [SELECT Id, Name, Hold_ID__c FROM Account WHERE Id = :ApexPages.currentPage().getParameters().get('id')].Hold_ID__c;
    }
    
      public PageReference save() {
         Audit_Questionnaire__c aq = new Audit_Questionnaire__c();
            aq.Name = txtSurvey;
            aq.account__c = apexpages.currentpage().getparameters().get('id');
            insert aq;
            return null;
        }
}
 
  • April 05, 2017
  • Like
  • 0
Hi all,

For external users, we will be sending a link in the email to fill survey and when they click submit.

1) A record should be created/saved into salesforce customOBject(Survey__c)
2)This Survey object has a lookup field which is Account, this should also be saved.

How do I achieve this? Please can you post the code.



 
  • April 04, 2017
  • Like
  • 0
Hi,

I have an old system which as ID for a table and I have created auto number ID field for an object in salesforce. 
Can I map them while data importing? 

TIA
  • January 31, 2017
  • Like
  • 0
When I click the edit button, the popup displays but does not display any data. Please help!
What is the mistake I'm doing it here.
what I have tried so far:

Visual Force:

<apex:page standardcontroller="UCF_REL__c" extensions="UCFController" sidebar="false" > 
<apex:sectionheader title="UCF Review" /> 
<apex:messages />
 <apex:form rendered="{!displaySection}"> 
<script type="text/javascript"> function LegalNameChangePopup(){ var newwindow = window.open('RELLegalNameChangePopup', 'name=_blank','height=500,width=500,left=250,top=100'); newwindow.focus(); } 
</script>
 <apex:pageblock title="General Information" > 
<apex:pageblocksection title="Legal Name"> 
<apex:panelgrid columns="2"> 
<!-- <apex:outputlabel value="Account Name: " for="accountName" />-->
 <apex:outputfield id="accountName" value="{!aaccount.name}"/>
 <apex:commandbutton value="Edit" id="accpopup" onclick="LegalNameChangePopup();" styleclass="btn"/>
 </apex:panelgrid>
 </apex:pageblocksection> 
</apex:pageblock> 
<apex:pageblock > 
<apex:pageblocksection columns="4"> 
<apex:commandbutton action="{!step2}" value="Save and Continue" styleclass="btn" />
 <apex:commandbutton action="{!reset}" value="Reset Page" styleclass="btn" immediate="true"/>
 </apex:pageblocksection>
 </apex:pageblock> 
</apex:form>
 </apex:page>

VF for popup: RELLegalNameChangePopup

<apex:page standardcontroller="UCF_REL__c" extensions="UCFController" showheader="false" sidebar="false" id="the">
  <apex:form id="page"> 
<apex:pageBlock >
 <apex:pageBlockSection columns="1" title="Legal Name change"> 
<apex:pageblocktable value="{!aAccount}" var="item" id="editAccountName">
 <apex:column headervalue="Proposed Legal Name">
 <apex:inputtext value="{!item.Name}" />
 </apex:column> </apex:pageblocktable>
 </apex:pageBlockSection> 
</apex:pageBlock>
 </apex:form>
  • June 05, 2018
  • Like
  • 0
I have REL_VS_Contact_Role__c field which is read only when the page loads. But when I click on the add new button(addContactObject). I wanted it to be editable, how do i achieve this?

Visualforce :

<apex:page standardcontroller="REL_VS_Submission__c" extensions="RELVSRenewalController" sidebar="false">
    <apex:sectionheader title="VSA Renewal Submission" subtitle="Step 2 of 10" />
    <apex:messages />
    <apex:form >
        <apex:pageblock title="Contact Information">
            Video providers must submit contact information for <b>at least 3 persons</b>: 1) the person authorized to receive information regarding the VSA; 2) the person designated to receive subscriber complaints and 3) the person designated to receive information regarding the annual cable assessment. If the data listed below is correct and complete, select save and continue. If any portion of the data is incorrect or missing, make the corrections now, then select save and continue.
            <!-- This facet tag defines the "Next" button that appears
            in the footer of the pageBlock. It calls the step2()
            controller method, which returns a pageReference to
            the next step of the wizard. -->
            <!--<apex:facet name="footer">
                <apex:commandbutton action="{!step3}" value="Save and Continue"
                                    styleclass="btn" />
            </apex:facet>-->
            <apex:variable value="{!0}" var="rowContactNumber" />
            <!-- Here we will use an extra variable to define a row number -->
            <apex:outputpanel id="panelWithVar">
                <apex:variable value="{!0}" var="rowContactNumber" />
            </apex:outputpanel>
            <apex:pageblocksection title="Contact Information" columns="1">
                <apex:pageblocktable value="{!anewContact}" var="item" id="newContactitems"  columnsWidth="5%,20%,10%,10%,10%,10%,5%,5%,5%,5%,10%,3%,2%">
                    <!-- A button to remove individual entry. s
                    We must to pass the line number to define a list entry number to remove -->
                    <apex:column headervalue="Delete">
                        <apex:commandbutton immediate="true" action="{!removeContactObject}" value=" X " rerender="newContactitems,panelWithVar">
                            <apex:param name="p2" value="{!rowContactNumber}" assignto="{!numberOfContactRowToRemove}" />
                        </apex:commandbutton>
                    </apex:column>
                    <!-- Moreover here we incrementing the row number variable -->
                    <!--<apex:column headerValue="RowCount">
                        <apex:outputText value="{!rowContactNumber}"/>
                    </apex:column>-->
                  
                   <apex:column headervalue="Role">
                        <apex:inputfield value="{!item.REL_VS_Contact_Role__c}" html-disabled="true"/>
                        <apex:variable var="rowContactNumber" value="{!rowContactNumber + 1}" />
                    </apex:column>
                    <apex:column headervalue="First Name">
                        <apex:inputfield value="{!item.Firstname}" required="true" />
                    </apex:column>
                    <apex:column headervalue="Last Name">
                        <apex:inputfield value="{!item.Lastname}" required="true" />
                    </apex:column>
                    <apex:column headervalue="Phone">
                        <apex:inputfield value="{!item.Phone}" required="true" />
                    </apex:column>
                    <apex:column headervalue="Fax">
                        <apex:inputfield value="{!item.Fax}" required="true" />
                    </apex:column>                  
                    <apex:column headervalue="Personal Email">
                        <apex:inputfield value="{!item.Email}" required="true" />
                    </apex:column>
                    <apex:column headervalue="General Email" >
                        <apex:inputfield value="{!item.REL_VS_Generic_Email__c}" />
                    </apex:column>
                    <apex:column headervalue="Title">
                        <apex:inputfield value="{!item.Title}" required="true"/>
                    </apex:column>
                     <apex:column headervalue="Mailing Street">
                        <apex:inputfield value="{!item.MailingStreet}" required="true"/>
                    </apex:column>
                    <apex:column headervalue="Mailing City">
                        <apex:inputfield value="{!item.MailingCity}" required="true"/>
                    </apex:column>
                    <apex:column headervalue="Mailing State">
                        <apex:inputfield value="{!item.MailingState}" required="true" />
                    </apex:column>
                    <apex:column headervalue="Mailing Zip">
                    <apex:inputfield value="{!item.MailingPostalCode}" required="true" />
                    </apex:column>
                 </apex:pageblocktable>
            </apex:pageblocksection>
            <!-- A main button to add a new item -->
            <apex:commandbutton value="Add Contact" action="{!addContactObject}" rerender="newContactitems,panelWithVar" immediate="true"/>

        </apex:pageblock>
        <apex:pageblock >
            <apex:pageblocksection columns="4">
                <apex:commandbutton action="{!step3}" value="Save and Continue"
                                    styleclass="btn" />
                <apex:commandbutton action="{!reset}" value="Reset Page"
                                    styleclass="btn" immediate="true" />
                <apex:commandbutton action="{!exit}" value="Exit"
                                    styleclass="btn" immediate="true" />
                <apex:commandbutton action="{!Back}" value="Back"
                                    styleclass="btn" immediate="true" />
            </apex:pageblocksection>
        </apex:pageblock>
    </apex:form>
</apex:page>
  • June 01, 2018
  • Like
  • 0
Hi,

I have a custom object that is related to the Contact object.  There are a couple fields (picklist, text, and date) where we want the user to be able to edit it on the custom object or the contact and it will update on both.  Is this possible?

Thanks!
Hi Friends,

I have a table (Detail) in SQL and creating a custom object in Salesforce (Detail__c). 
Below are the fields in SQL Detail Table:
User-added image

WIll they be a picklist? But how can I relate Detail_Acc_no, Description, TYpe and Detail_account_class all in one picklist? How can this be structured?


TIA

 
  • May 10, 2017
  • Like
  • 0
Hi all,

I have a VF page survey form for account which has certain questions. Each account can have multiple survey forms as per services availed.
I want to save these survey forms in a child object of Account.
How i should achieve this part?
Here is my code.
Class:


public with sharing class SurveyClass{

Public Account acc{get;set;}
Public List<Proposal_Form__c>pfc;
Public Proposal_Form__c pfc1 {get;set;}
public ProposalFields__c pf {get;set;}
public List<String> fieldSet {get;set;}
Public ID rid;
public string msg {get;set;}
private ApexPages.StandardController standardController;
    
public SurveyClass(ApexPages.StandardController controller) {
    this.standardController = standardController;
    pfc1 = new Proposal_Form__c();
  }

public void Selected(){
    system.debug(pfc1.Service_Family__c +'------------'+pfc1.Sub_Service_Category__c);
    
   /* try{
        pfc = [SELECT Fields_Associated__c FROM Proposal_Form__c where Service_Family__c =: pfc1.Service_Family__c and Sub_Service_Category__c =: pfc1.Sub_Service_Category__c LIMIT 1];
        
    } catch(NullPointerException ex){
        
          Apexpages.addMessage(new ApexPages.Message(ApexPages.SEVERITY.FATAL,'No such combination exists'+ex));
      
    } */
  
    pfc = new List<Proposal_Form__c>();
    pfc = [SELECT Fields_Associated__c FROM Proposal_Form__c where Service_Family__c =: pfc1.Service_Family__c and Sub_Service_Category__c =: pfc1.Sub_Service_Category__c LIMIT 1];

    if(!pfc.isEmpty())
    {
    fieldSet = new List<String>();
    List<String> fields = new List<String>();
     
    if(pfc[0].Fields_Associated__c != null && pfc[0].Fields_Associated__c != ''){
        fields = String.valueof(pfc[0].Fields_Associated__c).split(',');
        system.debug('*********Fields******'+fields);
    }
    else{
       ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'NO QUESTION SET FOUND'));
    }
   
    Map<String,String> labelMap = new Map<String,String>();
    labelMap = getLabel.retLabelMap('ProposalFields__c');
    system.debug(labelMap);
    system.debug(labelMap);
    for(String s : fields){
        fieldSet.add(labelMap.get(s));
        system.debug('********fieldset*******'+fieldSet);
    }    
  }
  else {
       ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'NO QUESTION SET FOUND'));
   }
 }  
}


VF Page:;;


<apex:page standardController="Account" extensions="SurveyClass" sidebar="false" showHeader="false" tabStyle="Account">
<apex:form >
<apex:pageMessages rendered="true" id="errMsg" showDetail="false"/>
<apex:pageBlock title="Customer Survey Form"> 

<apex:pageBlockSection title="Service Requirements" >
<apex:inputField value="{!pfc1.Service_Family__c}"/>
 <apex:pageblocksectionItem >
    <apex:outputLabel value="Sub Service Category"/>
    <apex:outputPanel >
        
            <apex:inputfield value="{!pfc1.Sub_Service_Category__c}">
                <apex:actionSupport event="onchange" action="{!Selected}" rerender="fieldst,errMsg" />
             </apex:inputField>
       
    </apex:outputPanel>
</apex:pageblocksectionItem>
</apex:pageBlockSection> 

<apex:pageblockSection title="Question Set" id="fieldst">
    <apex:repeat value="{!fieldSet}" var="f">
      <apex:inputField value="{!pf[f]}"/> 
    </apex:repeat>
</apex:pageblockSection>

<apex:pageBlockButtons location="bottom">
<apex:commandButton value="Submit" action="{!save}"/>
<apex:commandButton value="Edit" action="{!edit}"/>
</apex:pageBlockButtons>

</apex:pageBlock>
</apex:form> 
</apex:page>
Thanks,
Amita
 
Why is the label twice? I have a email__c field and trying to validate using apex on visualforce page. 
  • April 24, 2017
  • Like
  • 0
Hi All,

I'm trying to show an error message near the email field on visualforce page. Can I use ouputtext and innerhtml to display message?
Here is my code:

<apex:page id="thepage" controller="mySurvey">pt>
    <script type="text/javascript">
        var examNote = document.getElementsByClassName('examNote')[0].value;
        var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/i;
        var validEmail = re.test(examNote);
             if(validEmail == false) {
             alert("email not valid"); //checking if the code is reaching here by an alert message
             //code to show the error message on vf page instead of alert
            
     </script>
    <apex:form id="audit">
        <apex:pageblock id="pb1" >
          <apex:pageblockSection id="pbs1" columns="1">
            <p><apex:inputText value="{!account}" label="Account"/></p>
            <apex:inputText id="Survey" value="{!txtSurvey}" label="SurveyName"/>
            <apex:inputText id="examNote" value="{!examNote}" Label="Exam Note" styleClass="examNote"/>
            <apex:outputText value="{0}">
                <apex:param value="result"/>
            </apex:outputText>
              <apex:commandButton action="{!save}" onclick="return validate();" value="save"/>
          </apex:pageblockSection>
        </apex:pageblock>
    </apex:form>
</apex:page>
  • April 21, 2017
  • Like
  • 0
Can Someone help me write code in email templates to pull datd from SF.

My email are in regards to article approvals, rejections etc.

User-added image

I need to pull the following fields data out of the article into the email template but I do not know how to write code.

Title
Article #
Article type
Approval Status
Is latest version
Created by

Please help!

Adeline Moore
Hi,

I'm passing accountid as id and contactid in the url.

When the users click save, I need to update a datefield__c to today(without time) on contact object.

Here is my vf page - 
<apex:page controller="myAudit">
    <apex:form >
        <apex:pageblock >
          <apex:pageblockSection columns="1">
            <p><apex:inputText value="{!account}" label="Account"/></p>
            <apex:inputText id="Survey" value="{!txtSurvey}" label="SurveyName"/>
              <apex:commandButton action="{!save}" value="save"/>
          </apex:pageblockSection>
        </apex:pageblock>
    </apex:form>
</apex:page>

My apex class:
public class myAudit {

   public myAudit() {
    account =  [SELECT Id, Name FROM Account WHERE Id = :ApexPages.currentPage().getParameters().get('id')].Name;
   }

    public String account { get; set; }

    public String txtSurvey { get; set; }

    public PageReference save() {
         Audit_Questionnaire__c aq = new Audit_Questionnaire__c();
            aq.Name = txtSurvey;
            aq.account__c = apexpages.currentpage().getparameters().get('id');
            insert aq;
            return null;
        }
}
 
  • April 17, 2017
  • Like
  • 0