• AVINASH UPADHYA
  • NEWBIE
  • 50 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 11
    Replies
Hi All, 

Bellow i have given my code. Bassically I am tryin to impliment an Upload button which submits the user entered data and Upload the file to Document folder.
 
public class AppFormExtender {
    private final College_Aid_Application_Form__c ClgAppForm;
  //  Public static College_Aid_Application_Form__c College_Aid_Application_Form{get;set;}
    private ApexPages.StandardController controller;
    // Public Id PageId;     
    Public AppFormExtender (apexpages.standardController controller){
    ClgAppForm = (College_Aid_Application_Form__c)controller.getRecord();
    this.controller = controller;       
 
 }   
 
 public Document document {
    get {
      if (document == null)
        document = new Document();
      return document;
    }
    set;
  }
    
public boolean confirmAgreement() {
    if(!ClgAppForm.Signature__c) {
        return false;
    } else {
        return true;
    }
}
   
     Public PageReference Upload(){
        if(confirmAgreement()){        
            document.AuthorId = UserInfo.getUserId();
            document.FolderId = UserInfo.getUserId(); // put it in running user's folder

         try {
    
    insert document;
    
    } catch (DMLException e) {
      ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading file'));
      return null;
    }
            finally {
      document.body = null; // clears the viewstate
      document = new Document();
    }
          //Insert is commented to check the Upsert        
            Upsert ClgAppForm;
      //   PageReference acctPage = new ApexPages.StandardController(ClgAppForm).view();
       
       //PageReference FamilyDetail = new Apexpages.
     PageReference FamilyPage1 = Page.FamilyDetail;
     
            // FamilyPage1.getParameters().put('Family_Member_Detail__r' , ClgAppForm.Name);
             FamilyPage1.getParameters().put('PageId' , ClgAppForm.Id);
             FamilyPage1.setRedirect(true);
             return FamilyPage1;
         }else{
             ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Please check all agreement checkboxes before submitting.'));
        return null;
         }

 }
}
 
@isTest
public class AppFormExtenderTestClass {
    @isTest static void TestSubmissionForm(){
        
        PageReference pageRef = Page.College_Aid_Application_Form;
        Test.setCurrentPage(pageRef);  
        College_Aid_Application_Form__c Application1 = new College_Aid_Application_Form__c(E_mail__c='Avinash@gmail.com', Age__c=25, Birthday__c = date.today(), Village__c = 'Test Village',Province__c='Test Province',Country__c='India',Zip_Code__c=543213,No_Years_to_graduate__c=10,Signature__c=True);
       
        ApexPages.standardController controller = new ApexPages.standardController(Application1);
        AppFormExtender extensions  = new AppFormExtender(controller);
        
        //Document Upload procee test
        Document document = new document(body=Blob.valueOf('Unit Test Document Body'), name='Test Calss Document');
        //Submission of Application form.
        extensions.Upload();
       //Redirecting to Family Detail Page.
String nextPage=extensions.Upload().getUrl(); 
 System.assertEquals('/apex/familydetail?PageId='+Application1.Id,nextPage);
    }
}
My expectation is bellow part of the test code will cover entire Upload methode functionality. But its not covering the bold lettered code in the above code.
extensions.Upload();
       //Redirecting to Family Detail Page.
String nextPage=extensions.Upload().getUrl(); 
 System.assertEquals('/apex/familydetail?PageId='+Application1.Id,nextPage);

Can any one please share your thoughts where i am going wrong.

Regards,
Avinash Upadhya
 
Hi Guys,

I am trying to implement a "Save & New" button. My approach for this is use standard controller for Save functionality, and i am writing a new controller extension for Save & New functionality.

My Save&New functionality is behaving little Weird.. For the 1st time it will save the User entered name and if I press save&new for the remaining time it will save Records ID in place of Name even if user entered the name.
Also for me it doesn’t look like preferred approach. Please comment if you find anything with the below codes.
 
 
<apex:page standardController="Family_Member_Details__c" sidebar="false" showHeader="false" extensions="FamilyDetailExtender">
<apex:form >
<apex:pageMessages />
<center><font size="5"><b><p>Family Information
</p> 
</b>
</font>
</center>

<apex:pageBlock >
<table style="width:100%">
   <tr><font size="3">
       <b> Family Member Name: </b><br/><apex:inputfield value="{!Family_Member_Details__c.Name}"/></font></tr>
    </table>
    </apex:pageBlock>
    <apex:commandButton action="{!Save}" value="Save"/>
    <apex:commandButton action="{!SaveANDNew}" value="Save and New"/>
    </apex:form>
</apex:page>

Controller extension:
public class FamilyDetailExtender {
//Variable to get the Id from the URL of which is passed from previous program.
Public final Id PageId;
public final Id ApplicationForm;

Public Family_Member_Details__c FamilyDetail1;

    
    Public FamilyDetailExtender(Apexpages.StandardController Fmly){
    FamilyDetail1 = (Family_Member_Details__c)Fmly.getRecord();
        PageId = System.currentPagereference().getParameters().get('PageId');

        FamilyDetail1.Application_Form__c  = [select Id,Name from College_Aid_Application_Form__c where Id = :PageId LIMIT 1].Id;

//Storing the Application ID so that this can be used when user press save and new.

        ApplicationForm = FamilyDetail1.Application_Form__c;
    }


// Write a methode for Save and New Custom button.

Public PageReference SaveANDNew(){

    system.debug('----------------------------------------->'+ApplicationForm);
    // This is the required field and since we masking this field in screen, in program we populating Application ID when user press Save and new.
 FamilyDetail1.Application_Form__c =  ApplicationForm;

//Insert is used to impliment the Save functionality.
Insert FamilyDetail1;

// After saving the record below code is expected to load the page with blank values so that user can enter the new value.
    FamilyDetail1 = new Family_Member_Details__c();
    PageReference FamilyPage1 = Page.FamilyDetail;
     
            // FamilyPage1.getParameters().put('Family_Member_Detail__r' , ClgAppForm.Name);
             FamilyPage1.getParameters().put('PageId' , PageId);
  
            
    return FamilyPage1;
    
   
}
}

Thanks guys for the awesome support :)
Hi All,
I have got a Master Objtect which is application_Forcm__c and Detail/Child Object is Family_Detail__c.

Master child relation name is Family_Detail_Info.

Requirement:
Once user fills the Application page details and submits page redirects to Family detail Page where user enters Family deails which will be associated with the application form.
I am using controller extension on Family Detail page, and i want whatever Family Data entered by user it should be automaticaly mapped to Application form he submitted.

Basically i want to skip pressing search application button and selecting application form number as shown bellow.
User-added image
How can i do this suggest me please.

My Approch: From Application form page i am passing the Application form Id which user just submitted, And i will SOQL and get the Appliction From Number. But problem with this is i am not getting what name i should use in INSERT Statment of Family Detail so that application form number is mapped. 
Hello All,
Can any one please tell me what are the permissions are required to allow a VF Page/App to give a public acess as in the bellow URL
http://demopoint-developer-edition.ap1.force.com/apex/wrapperAccountSelect

It looks like we need to use Site.com.. If yes please give some suggetions on what are the setups required for this?

Thanks in advance!
Avinash
Hi Friends,
I have stuck with two small requirements, please help me to find the solution to this.

I have a VF page, and am using a standard controller. This VF has only save option. Now i want to save only if a check box in the page is checked, this check box is kind of I AGREE statment.

Another requirement is that in the same page i need to provide a option to upload the image and when user save it image also should be saved.

Thank you.
Avinash

Hi All,

I am trying to build a Simpale calculator in different way. I have created a custome object Calculator__C having 3 fields Var1, Var2, Result.

Bellow is the controller for same but its not working. Please suggest me what needs be modified in bellow code.

public class CalculatorController {
    public Calculator__C  Calc  {get; set;}
   
Public void Add(){
      Calc.Result__c = Calc.Var1__c + Calc.Var2__c; 
        }
Public void Sub(){
      Calc.Result__c = Calc.Var1__c - Calc.Var2__c; 
    }  
Public void Div(){
     Calc.Result__c = Calc.Var1__c / Calc.Var2__c; 
    }
   
}
Hi All,
I need to pull one single report, Its like combining of two reports.. Contacts with sponsership details also contacts with affiliation details.
Sponsership has lookup field to contact and Affiliation too.. How can i cobine all these data in single report ??

Thanks.
Hi Friends,
I am facing one small issue. I am trying to generate a reports from the contact object. When i run the report without ANY Filter conditions it is giving me a only 50 records but when i run a query on my contacts it has more than 5k+ records.

Can you please tell me why my reports are getting less records?

Thanks in advance!
Hi All,

Can anyone please help me with bellow challenge.


Create an Apex trigger for Account that matches Shipping Address Postal Code with Billing Address Postal Code based on a custom field.
For this challenge, you need to create a trigger that, before insert or update, checks for a checkbox, and if the checkbox field is true, sets the Shipping Postal Code (whose API name is ShippingPostalCode) to be the same as the Billing Postal Code (BillingPostalCode).The Apex trigger must be called 'AccountAddressTrigger'.
The Account object will need a new custom checkbox that should have the Field Label 'Match Billing Address' and Field Name of 'Match_Billing_Address'. The resulting API Name should be 'Match_Billing_Address__c'.
With 'AccountAddressTrigger' active, if an Account has a Billing Postal Code and 'Match_Billing_Address__c' is true, the record should have the Shipping Postal Code set to match on insert or update.

For above challenge i tried with following code but looks like it doesnt mach the requirement.

trigger AccountAddressTrigger on Account (before insert, before update) {
    for(Account a : Trigger.new){
        If (a.Match_Billing_Address__c = true) {
            /*ShippingPostalCode = BillingPostalCode;*/
        }   
    } 

}

Please help me
Hi All,
I am a learner in this platform. I was waondering is there any meterial which can help me to understand the use of Standard objects in slaesforce.

If you know any such meterial please suggest me the same.

Thanks in advance.
Hi All,
Can any one please tell me is there any other workbook is present like "Recruiting App workbook" over the web?

Thanks in advance :) 
Hi All,

Can anyone please help me with bellow challenge.


Create an Apex trigger for Account that matches Shipping Address Postal Code with Billing Address Postal Code based on a custom field.
For this challenge, you need to create a trigger that, before insert or update, checks for a checkbox, and if the checkbox field is true, sets the Shipping Postal Code (whose API name is ShippingPostalCode) to be the same as the Billing Postal Code (BillingPostalCode).The Apex trigger must be called 'AccountAddressTrigger'.
The Account object will need a new custom checkbox that should have the Field Label 'Match Billing Address' and Field Name of 'Match_Billing_Address'. The resulting API Name should be 'Match_Billing_Address__c'.
With 'AccountAddressTrigger' active, if an Account has a Billing Postal Code and 'Match_Billing_Address__c' is true, the record should have the Shipping Postal Code set to match on insert or update.

For above challenge i tried with following code but looks like it doesnt mach the requirement.

trigger AccountAddressTrigger on Account (before insert, before update) {
    for(Account a : Trigger.new){
        If (a.Match_Billing_Address__c = true) {
            /*ShippingPostalCode = BillingPostalCode;*/
        }   
    } 

}

Please help me
Hi All,
I have got a Master Objtect which is application_Forcm__c and Detail/Child Object is Family_Detail__c.

Master child relation name is Family_Detail_Info.

Requirement:
Once user fills the Application page details and submits page redirects to Family detail Page where user enters Family deails which will be associated with the application form.
I am using controller extension on Family Detail page, and i want whatever Family Data entered by user it should be automaticaly mapped to Application form he submitted.

Basically i want to skip pressing search application button and selecting application form number as shown bellow.
User-added image
How can i do this suggest me please.

My Approch: From Application form page i am passing the Application form Id which user just submitted, And i will SOQL and get the Appliction From Number. But problem with this is i am not getting what name i should use in INSERT Statment of Family Detail so that application form number is mapped. 
Hello All,
Can any one please tell me what are the permissions are required to allow a VF Page/App to give a public acess as in the bellow URL
http://demopoint-developer-edition.ap1.force.com/apex/wrapperAccountSelect

It looks like we need to use Site.com.. If yes please give some suggetions on what are the setups required for this?

Thanks in advance!
Avinash

Hi All,

I am trying to build a Simpale calculator in different way. I have created a custome object Calculator__C having 3 fields Var1, Var2, Result.

Bellow is the controller for same but its not working. Please suggest me what needs be modified in bellow code.

public class CalculatorController {
    public Calculator__C  Calc  {get; set;}
   
Public void Add(){
      Calc.Result__c = Calc.Var1__c + Calc.Var2__c; 
        }
Public void Sub(){
      Calc.Result__c = Calc.Var1__c - Calc.Var2__c; 
    }  
Public void Div(){
     Calc.Result__c = Calc.Var1__c / Calc.Var2__c; 
    }
   
}
Hi All,
I need to pull one single report, Its like combining of two reports.. Contacts with sponsership details also contacts with affiliation details.
Sponsership has lookup field to contact and Affiliation too.. How can i cobine all these data in single report ??

Thanks.
Hi Friends,
I am facing one small issue. I am trying to generate a reports from the contact object. When i run the report without ANY Filter conditions it is giving me a only 50 records but when i run a query on my contacts it has more than 5k+ records.

Can you please tell me why my reports are getting less records?

Thanks in advance!
Hi All,

Can anyone please help me with bellow challenge.


Create an Apex trigger for Account that matches Shipping Address Postal Code with Billing Address Postal Code based on a custom field.
For this challenge, you need to create a trigger that, before insert or update, checks for a checkbox, and if the checkbox field is true, sets the Shipping Postal Code (whose API name is ShippingPostalCode) to be the same as the Billing Postal Code (BillingPostalCode).The Apex trigger must be called 'AccountAddressTrigger'.
The Account object will need a new custom checkbox that should have the Field Label 'Match Billing Address' and Field Name of 'Match_Billing_Address'. The resulting API Name should be 'Match_Billing_Address__c'.
With 'AccountAddressTrigger' active, if an Account has a Billing Postal Code and 'Match_Billing_Address__c' is true, the record should have the Shipping Postal Code set to match on insert or update.

For above challenge i tried with following code but looks like it doesnt mach the requirement.

trigger AccountAddressTrigger on Account (before insert, before update) {
    for(Account a : Trigger.new){
        If (a.Match_Billing_Address__c = true) {
            /*ShippingPostalCode = BillingPostalCode;*/
        }   
    } 

}

Please help me
Hi All,
I am a learner in this platform. I was waondering is there any meterial which can help me to understand the use of Standard objects in slaesforce.

If you know any such meterial please suggest me the same.

Thanks in advance.