• Ayush Tripathi
  • NEWBIE
  • 95 Points
  • Member since 2017
  • Salesforce Developer
  • Xceedance Technology


  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 37
    Replies
apex class :
public with sharing class EnrollmentFormClass {
public Contact con {get;set;}
public Contact conc {get;set;}
public Contact conct {get;set;}
public List<Contact> concAddList{get;set;}
public Account acc {get;set;}
    
public EnrollmentFormClass() {
     con  = new Contact();
     conc = new Contact();
     conct = new Contact();
     acc  = new Account();
     concAddList  = new List<Contact>();  
     //concAddList.add(con);
     }
    public void AddRow(){
        conct = new Contact();
        concAddList.add(conct);
        //concAddList.add(new Contact());
    }
public void save(){
    insert con;    
    acc.name = con.lastName;
    insert acc;
    con.AccountId = acc.Id;
    conc.AccountId = acc.Id;
    conct.AccountId = acc.Id;
    
    insert conc;
    insert conct;
    insert concAddList;
    update con;
   
    }
     
}
visualforcepage :

<apex:page controller="EnrollmentFormClass">
    <apex:form >
    <apex:pageBlock title="Opportunitiy Zone Enrollment Form">
              <apex:pageBlockSection columns="3">
              <apex:inputField value="{!con.Student_Name__c}"/>
              <apex:inputField value="{!con.School__c}"/> 
              <apex:inputField value="{!con.Date__c}"/> 
            </apex:pageBlockSection>
            <br/> 
            <br/>
                    SPARC programs are funded by United Way of Greater Atlanta. As such, we are required to report demographic, income, educational and health access information on every individual/family we serve. With the United Way belief that serving one family member serves them all, we collect general information on each member of your household. We appreciate your willingness to complete this form in its entirety so that we can continue providing free programs to the community. Thank you!
            <br/>  
            <br/> 
            <apex:pageBlockSection title="Head of Household Information:">
                <apex:inputField value="{!con.FirstName}"/>
                <apex:inputField value="{!con.LastName}"/>
                <apex:inputField value="{!con.Date_of_Birth__c}"/>
                <apex:inputField value="{!con.Gender__c}"/> 
                <apex:inputField value="{!con.Do_you_have_a_primary_medical_provider__c}"/>
                <apex:inputField value="{!con.Do_you_have_a_primary_medical_provider__c}"/>
                <apex:inputField value="{!con.Address__c}"/>
                <apex:inputField value="{!con.City__c}"/>
                <apex:inputField value="{!con.State__c}"/>
                <apex:inputField value="{!con.County__c}"/>
                <apex:inputField value="{!con.Phone__c}"/>
                <apex:inputField value="{!con.Email_Address__c}"/>
                <apex:inputField value="{!con.Preferred_Method_of_Contact_Circle_One__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlocksection title="Demographic Data: (All information is confidential and is used in applying for grants to fund this program.)" columns="3">
                 <apex:inputField value="{!con.Spanish_translation_Services_Needed__c}"/>
                 <apex:inputField value="{!con.Race_Check_One__c}"/>
                 <apex:inputField value="{!con.Marital_Status_check_one__c}"/>
                 <apex:inputField value="{!con.HIGHEST_LEVEL_OF_EDUCATION_Check_one__c}"/>
                 <apex:inputField value="{!con.Employment_check_one__c}"/>
            </apex:pageBlocksection>
            <apex:pageBlocksection title="Income:" columns="3">
                <apex:inputField value="{!con.Annual_Income__c}"/> 
                <apex:inputField value="{!con.Source_of_Income__c}"/> 
                <apex:inputField value="{!con.Primary_Method_of_Transportation__c}"/>
            </apex:pageBlocksection>
            <apex:pageBlocksection title="HOUSEHOLD Information:" columns="3">
                <apex:inputField value="{!conc.Other_Adult_First_Name__c}"/>
                <apex:inputField value="{!conc.LastName}"/>
                <apex:inputField value="{!conc.Date_of_Birth__c}"/>
                <apex:inputField value="{!conc.Gender__c}"/> 
                <apex:inputField value="{!conc.Relationship_Primary_Care_Provider__c}"/>
                <apex:inputField value="{!conc.Medical_Insurance__c    }"/> 
            </apex:pageBlocksection>
                <apex:pageBlockButtons location="bottom" >
                <apex:commandButton action="{!save}" value="save"/>
            </apex:pageBlockButtons> 
            <apex:pageBlocksection title="Children (all children currently in your household, INCLUDING those participating in this program):" columns="1">
             <apex:pageBlockTable value="{!conct}" var="c">
             <apex:column headerValue="Name">
             <apex:commandButton action="{!AddRow}" value="AddRow"/>
             </apex:column>
             <apex:column headerValue="Name">
             <apex:inputfield value="{!c.LastName}"/>  
             </apex:column> 
             <apex:column headerValue="Date of Birth">
             <apex:inputfield value="{!c.Date_of_Birth__c}"/>
             </apex:column>
             <apex:column headerValue="Gender">
             <apex:inputfield value="{!c.Gender__c}"/>
             </apex:column>
             <apex:column headerValue="Relationship Primary Care Provider">
             <apex:inputfield value="{!c.Relationship_Primary_Care_Provider__c}"/>
             </apex:column>
             <apex:column headerValue="Medical Insurance">
             <apex:inputfield value="{!c.Medical_Insurance__c}"/>
             </apex:column>             
       </apex:pageBlockTable> 
       </apex:pageBlocksection>
       </apex:pageBlock>
    </apex:form>
</apex:page>
  • February 13, 2018
  • Like
  • 0
Hi all,

I have two objects in Master Detail relationship.
Ticket__c  is a Master and Ticket_item__c is Child.
I have related list of Ticket_item__c in Ticket__c but it is standard page and it will show only 10 columns.
I want to display the Ticket_item_c list in Ticket Page Layout with 12 columns. 
Can you please point any sample visualfore page on how to write this.  

Thank you
I am trying to change my date format to mm/dd/yy Here is my code (I bolded the line that contains the date):

<messaging:emailTemplate subject="Reserve Your Buy a Day" recipientType="Contact" relatedToType="Opportunity">
    <messaging:htmlEmailBody >
        <body style="font-family: 'Trebuchet MS'">
            <h2>
                Opportunity with Products</h2>
            <hr style="border: solid thin #0099CC" />
            <br />
            <table cellpadding="5" style="border-collapse: collapse" width="100%">
                <tr>
                    <td align="right" 
                        style="border-right-style: solid; border-right-width: thick; border-right-color: #0099CC;" 
                        width="20%">
                        <i>Name</i>
                    </td>
                    <td width="80%">
                        <b>{!relatedTo.Name}</b>
                    </td>
                </tr>
                <tr>
                    <td align="right" 
                        style="border-right-style: solid; border-right-width: thick; border-right-color: #0099CC;" 
                        width="20%">
                        <i>Amount</i>
                    </td>
                    <td width="80%">
                        <b>{!relatedTo.Amount}</b>
                    </td>
                </tr>

           
            </table>
            <br />
            <table cellpadding="5" style="border-collapse: collapse" width="100%">
                <tr>
                    <td style="background-color: #0099CC; color: #FFFFFF">
                        <b>In Memory or Honor</b>
                    </td>
                    <td style="background-color: #0099CC; color: #FFFFFF">
                        <b>Date Reserved</b>
                    </td>
                    <td style="background-color: #0099CC; color: #FFFFFF">
                        <b>Name of Recognition</b>
                    </td>
                </tr>
                <apex:repeat value="{!relatedTo.OpportunityLineItems}" var="lineItem">
                        <tr>
                            <td>
                                {!lineItem.Donation_Type__c}
                            </td>
                            <td>
                                {!lineItem.Calendar_Day_Reserved__c}
                            </td>
                            <td>
                                {!lineItem.Name_of_Recognition__c}
                            </td>
                            <td>
                            </td>                                                            
                        </tr>
                </apex:repeat>
            </table>
        </body>
    </messaging:htmlEmailBody>
</messaging:emailTemplate>
Hello all
This is an very urgent requirement.

I have a parent visualforce page called Med which has 4 fields say approver_1 , approver_2 , approver_3 and approver_4 which is lookup to user.

I have a button which opens a visualforce page as a popup.

The code for the popup visualforce page is as follows:

vf page:
=======
<apex:page standardController="MedConnect__FDA_3500A_MedWatch_Report__c" extensions="VY_InitiateApprovalProcess_Controller" lightningStylesheets="true">
<apex:includeScript value="{!$Resource.MedConnect__jquery}" />
    <apex:includeScript value="{!URLFOR($Resource.MedConnect__jquery_ui,'jquery-ui-1.10.3/ui/minified/jquery-ui.min.js')}"/>
    <apex:stylesheet value="{!URLFOR($Resource.MedConnect__jquery_ui,'jquery-ui-1.10.3/themes/base/jquery-ui.css')}"/>
<apex:form >
<apex:pageBlock mode="edit">
<apex:pageBlockSection title="Approvers" id="ApproversId">
    <apex:inputField Id="appId1" html-placeholder="Search People..." value="{!Approver.VY_Approver1__c}" />
    <apex:inputField Id="appId2" html-placeholder="Search People..." value="{!Approver.VY_Approver2__c}" />
    </apex:pageBlockSection>
    <apex:pageBlockSection >
    <apex:inputField Id="appId3" html-placeholder="Search People..." value="{!Approver.VY_Approver3__c}" />
    <apex:inputField Id="appId4" html-placeholder="Search People..." value="{!Approver.VY_Approver4__c}" />
    </apex:pageBlockSection>
    <apex:pageBlockButtons location="bottom" html-align="right">
    <button class="btn" onclick="window.open('/{!$CurrentPage.parameters.id}', target='_self');return false;">Cancel</button>
     <apex:commandButton action="{!customSave}" value="Save" onClick="Window.Close()" onomplete="window.top.location.reload()"/>
     
    </apex:pageBlockButtons>
    </apex:pageBlock>
</apex:form>
    <script language="JavaScript" type="text/javascript">
function CloseAndRefresh(){
window.opener.location.href="/{!$CurrentPage.parameters.ID}";
      self.close();
  }
</script>
</apex:page>

apex controller of poup page
======================
public with sharing class VY_InitiateApprovalProcess_Controller
{
    public id ReportIds;
    public MedConnect__FDA_3500A_MedWatch_Report__c Approver { get; set; }
   
    public VY_InitiateApprovalProcess_Controller(ApexPages.StandardController controller) {
        ReportIds = ApexPages.CurrentPage().getParameters().get('id');
        this.Approver = (MedConnect__FDA_3500A_MedWatch_Report__c)controller.getRecord();
        Approver =[SELECT Id,VY_Approver1__c,VY_Approver2__c,VY_Approver3__c,VY_Approver4__c
                            FROM
                            MedConnect__FDA_3500A_MedWatch_Report__c WHERE Id =:ReportIds];
    }
    public VY_InitiateApprovalProcess_Controller()
    {
        Approver = new MedConnect__FDA_3500A_MedWatch_Report__c();
    }
   
    public PageReference customSave()
    {
        PageReference pr;
        try{
            database.upsert(Approver);
            //closeWindow = true;
            pr = new PageReference('/'+Approver.Id );
        }catch( Exception e ){
            ApexPages.addMessages(e);
        }
        return Null;       
    }
   
}  

Once I hit the save button then it should close and the parent visualforce page should refresh showing the field values.

Also when I click cancel, then the popup page should close.

I am not able to get this straight.

Please respond with earliest and eloborate.

thanks
shweta

 
<apex:page standardcontroller="Mycustomobject" extensions="dosomework">
<apex:form>
<apex:commandbutton action="{!dosomework}" value="GO!"/>
</apex:form>
</apex:page>

This is my Skeltal Code. when i try to save it I am getting error like - Can not find Mycustomobject.stdcontollerdosomework
dosomework is in extension.

Why the code is checking for method in standard controller and not in extension?
  • February 15, 2018
  • Like
  • 0
Hi All,
I have two object one is Bank__c and another one is customer__c. Customer data I am getting from external system (SAP). From SAP I will select the customers and then I will select the bank to map. All customers will showing everytime. If Customer1 is linked to Bank1 then Customer1 sholud not be allowed to map to another Bank. How can I do this?
Please help me.
Thanks in Advance
apex class :
public with sharing class EnrollmentFormClass {
public Contact con {get;set;}
public Contact conc {get;set;}
public Contact conct {get;set;}
public List<Contact> concAddList{get;set;}
public Account acc {get;set;}
    
public EnrollmentFormClass() {
     con  = new Contact();
     conc = new Contact();
     conct = new Contact();
     acc  = new Account();
     concAddList  = new List<Contact>();  
     //concAddList.add(con);
     }
    public void AddRow(){
        conct = new Contact();
        concAddList.add(conct);
        //concAddList.add(new Contact());
    }
public void save(){
    insert con;    
    acc.name = con.lastName;
    insert acc;
    con.AccountId = acc.Id;
    conc.AccountId = acc.Id;
    conct.AccountId = acc.Id;
    
    insert conc;
    insert conct;
    insert concAddList;
    update con;
   
    }
     
}
visualforcepage :

<apex:page controller="EnrollmentFormClass">
    <apex:form >
    <apex:pageBlock title="Opportunitiy Zone Enrollment Form">
              <apex:pageBlockSection columns="3">
              <apex:inputField value="{!con.Student_Name__c}"/>
              <apex:inputField value="{!con.School__c}"/> 
              <apex:inputField value="{!con.Date__c}"/> 
            </apex:pageBlockSection>
            <br/> 
            <br/>
                    SPARC programs are funded by United Way of Greater Atlanta. As such, we are required to report demographic, income, educational and health access information on every individual/family we serve. With the United Way belief that serving one family member serves them all, we collect general information on each member of your household. We appreciate your willingness to complete this form in its entirety so that we can continue providing free programs to the community. Thank you!
            <br/>  
            <br/> 
            <apex:pageBlockSection title="Head of Household Information:">
                <apex:inputField value="{!con.FirstName}"/>
                <apex:inputField value="{!con.LastName}"/>
                <apex:inputField value="{!con.Date_of_Birth__c}"/>
                <apex:inputField value="{!con.Gender__c}"/> 
                <apex:inputField value="{!con.Do_you_have_a_primary_medical_provider__c}"/>
                <apex:inputField value="{!con.Do_you_have_a_primary_medical_provider__c}"/>
                <apex:inputField value="{!con.Address__c}"/>
                <apex:inputField value="{!con.City__c}"/>
                <apex:inputField value="{!con.State__c}"/>
                <apex:inputField value="{!con.County__c}"/>
                <apex:inputField value="{!con.Phone__c}"/>
                <apex:inputField value="{!con.Email_Address__c}"/>
                <apex:inputField value="{!con.Preferred_Method_of_Contact_Circle_One__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlocksection title="Demographic Data: (All information is confidential and is used in applying for grants to fund this program.)" columns="3">
                 <apex:inputField value="{!con.Spanish_translation_Services_Needed__c}"/>
                 <apex:inputField value="{!con.Race_Check_One__c}"/>
                 <apex:inputField value="{!con.Marital_Status_check_one__c}"/>
                 <apex:inputField value="{!con.HIGHEST_LEVEL_OF_EDUCATION_Check_one__c}"/>
                 <apex:inputField value="{!con.Employment_check_one__c}"/>
            </apex:pageBlocksection>
            <apex:pageBlocksection title="Income:" columns="3">
                <apex:inputField value="{!con.Annual_Income__c}"/> 
                <apex:inputField value="{!con.Source_of_Income__c}"/> 
                <apex:inputField value="{!con.Primary_Method_of_Transportation__c}"/>
            </apex:pageBlocksection>
            <apex:pageBlocksection title="HOUSEHOLD Information:" columns="3">
                <apex:inputField value="{!conc.Other_Adult_First_Name__c}"/>
                <apex:inputField value="{!conc.LastName}"/>
                <apex:inputField value="{!conc.Date_of_Birth__c}"/>
                <apex:inputField value="{!conc.Gender__c}"/> 
                <apex:inputField value="{!conc.Relationship_Primary_Care_Provider__c}"/>
                <apex:inputField value="{!conc.Medical_Insurance__c    }"/> 
            </apex:pageBlocksection>
                <apex:pageBlockButtons location="bottom" >
                <apex:commandButton action="{!save}" value="save"/>
            </apex:pageBlockButtons> 
            <apex:pageBlocksection title="Children (all children currently in your household, INCLUDING those participating in this program):" columns="1">
             <apex:pageBlockTable value="{!conct}" var="c">
             <apex:column headerValue="Name">
             <apex:commandButton action="{!AddRow}" value="AddRow"/>
             </apex:column>
             <apex:column headerValue="Name">
             <apex:inputfield value="{!c.LastName}"/>  
             </apex:column> 
             <apex:column headerValue="Date of Birth">
             <apex:inputfield value="{!c.Date_of_Birth__c}"/>
             </apex:column>
             <apex:column headerValue="Gender">
             <apex:inputfield value="{!c.Gender__c}"/>
             </apex:column>
             <apex:column headerValue="Relationship Primary Care Provider">
             <apex:inputfield value="{!c.Relationship_Primary_Care_Provider__c}"/>
             </apex:column>
             <apex:column headerValue="Medical Insurance">
             <apex:inputfield value="{!c.Medical_Insurance__c}"/>
             </apex:column>             
       </apex:pageBlockTable> 
       </apex:pageBlocksection>
       </apex:pageBlock>
    </apex:form>
</apex:page>
  • February 13, 2018
  • Like
  • 0
Hi All,

I am giving inputs at run time, after hitting save button my records should get saved and display the record detail page. Here, I am using Standardcontroller = 'Lead'
<apex:page standardController="Lead" extensions="TrialReController" sidebar="false" showHeader="false">
<apex:form id="frm">
<apex:pageblock>
 <apex:pageblockButtons location="bottom">  
    <apex:commandButton value="Save" action="{!Save}" rendered="true" />
</apex:pageblockButtons>
<apex:pageblocksection columns="1">
    <apex:inputfield value="{!lead.FirstName}"/>
    <apex:inputfield value="{!lead.lastname}"/>
    <apex:inputfield value="{!lead.Phone}"/>
    <apex:inputfield value="{!lead.Email}"/> 
    <apex:inputfield value="{!lead.Account__c}"/> 
</apex:pageblocksection>
</apex:pageblock>
</apex:form>
</apex:page>
********************************************************
public class TrialReController {
    public boolean x{get;set;}
    public boolean y{get;set;}
    public Lead lead{get;set;}
    public TrialReController(ApexPages.StandardController controller) {
        Lead lead = new Lead();
    }
    public void Save(){
        insert Lead;     //used upsert also, still not working
        //return new PageReference('/'+Lead.Id);
       }
}

I am not able to save my records its throwing error :
Attempt to de-reference a null object
Error is in expression '{!Save}' in component <apex:commandButton> in page trialredesign: Class.TrialReController.Save: line 29, column 1

Many many thanks for your help..!!
Hi,

I want to display my Start button at first and when the user clicks on it then display ShowProducts button.
My Vf page :
<apex:page standardController="Lead" extensions="TrialReController" sidebar="false" showHeader="false">
<apex:form id="frm">
<apex:pageblock>
<apex:pageblockButtons location="bottom">
   <apex:commandButton value="Start" action="{!start}" rendered="{!x}" />
    <apex:commandButton value="ShowProducts" action="{!ShowProducts}" rendered="{!y}" />
</apex:pageblockButtons>

</apex:pageblock>
</apex:form>
</apex:page>
***************************************
public class TrialReController {
    public boolean x{get;set;}
    public boolean y{get;set;}
    public TrialReController(ApexPages.StandardController controller) {

    }
    public void start(){
        x=true;
        check();
    }
    public void ShowProducts(){
        y=true;
        check();
    }
    public void check(){
        if(x == true){
            y=false;
        }
        else{
            x=false;
        }
    }
}

When I am previewing my output I can't see any button there.
Many thanks for your help.!!
Hi all,

I have two objects in Master Detail relationship.
Ticket__c  is a Master and Ticket_item__c is Child.
I have related list of Ticket_item__c in Ticket__c but it is standard page and it will show only 10 columns.
I want to display the Ticket_item_c list in Ticket Page Layout with 12 columns. 
Can you please point any sample visualfore page on how to write this.  

Thank you
I've a  string field conatins date  as 'month & year' example  '1 2018', '2 2018'.  I want to get month start date and moth end date for that custom string field. how can i archive that.?

HI Friends, 
I got stricked please do help. 
We have custom execute javascript button which used to call third party api and using in classic mode. but now we moved to communities so now we are unable to show javascript button on communities pages. because lightning pages not supporting for javascrript buttons. 
Please do help with lightning componenets and vf how to do, because am not familier with lightning. 
Please do help.

Currently we have this java script button 

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")} 

var result = sforce.apex.execute("GeneratingNewDocLinkForLoanInDB","GeneratingDocLink", {extrnlid:"{!Loan__c.Loan_External_id__c}"}); 
location.reload();

 Thanks in Advance.

  • February 06, 2018
  • Like
  • 0
I am trying to change my date format to mm/dd/yy Here is my code (I bolded the line that contains the date):

<messaging:emailTemplate subject="Reserve Your Buy a Day" recipientType="Contact" relatedToType="Opportunity">
    <messaging:htmlEmailBody >
        <body style="font-family: 'Trebuchet MS'">
            <h2>
                Opportunity with Products</h2>
            <hr style="border: solid thin #0099CC" />
            <br />
            <table cellpadding="5" style="border-collapse: collapse" width="100%">
                <tr>
                    <td align="right" 
                        style="border-right-style: solid; border-right-width: thick; border-right-color: #0099CC;" 
                        width="20%">
                        <i>Name</i>
                    </td>
                    <td width="80%">
                        <b>{!relatedTo.Name}</b>
                    </td>
                </tr>
                <tr>
                    <td align="right" 
                        style="border-right-style: solid; border-right-width: thick; border-right-color: #0099CC;" 
                        width="20%">
                        <i>Amount</i>
                    </td>
                    <td width="80%">
                        <b>{!relatedTo.Amount}</b>
                    </td>
                </tr>

           
            </table>
            <br />
            <table cellpadding="5" style="border-collapse: collapse" width="100%">
                <tr>
                    <td style="background-color: #0099CC; color: #FFFFFF">
                        <b>In Memory or Honor</b>
                    </td>
                    <td style="background-color: #0099CC; color: #FFFFFF">
                        <b>Date Reserved</b>
                    </td>
                    <td style="background-color: #0099CC; color: #FFFFFF">
                        <b>Name of Recognition</b>
                    </td>
                </tr>
                <apex:repeat value="{!relatedTo.OpportunityLineItems}" var="lineItem">
                        <tr>
                            <td>
                                {!lineItem.Donation_Type__c}
                            </td>
                            <td>
                                {!lineItem.Calendar_Day_Reserved__c}
                            </td>
                            <td>
                                {!lineItem.Name_of_Recognition__c}
                            </td>
                            <td>
                            </td>                                                            
                        </tr>
                </apex:repeat>
            </table>
        </body>
    </messaging:htmlEmailBody>
</messaging:emailTemplate>
Im tryig to convert a JS button to work as lightning button or even could be a quick action
{!REQUIRESCRIPT('/soap/ajax/19.0/connection.js')}

function updatefield() {
var record = new sforce.SObject('CustomObject__c');
record.id = '{!CustomObjec__c.Id}';
record.CheckBox__c = 'true';
var records=new Array();
records[0]=record;
var result = sforce.connection.update(records);
if (result[0].getBoolean("success")) window.location.reload()
else alert(result[0].errors.message);
}
try{
updatefield();
}
catch(ex){
alert(ex);
}

According to this Im creating a update a record qucik action n pre defining the check box to true but it isnt quite working or may be Im reading the code wrong??
Hello,

I want to write code to populate the following ONLY when populated; 

"Date of Birth: XX/XX/XXXX" 

I am having trouble having the 'Date of Birth:' part render without and error.

My code currently has 'Date of Birth' in the template the entire time.

Code: 

<apex:outputText value="{0, date, MM-dd-yyyy}"> 
           Date of Birth:<apex:Param value="{!IF(NOT(ISBLANK(relatedTo.Date_of_Birth__c)),relatedTo.Date_of_Birth__c, '')}" />
           </apex:OutputText>


Thanks