+ Start a Discussion
AVINASH UPADHYAAVINASH UPADHYA 

Update.Insert to Master detail Relationship

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. 
Best Answer chosen by AVINASH UPADHYA
Anupam RastogiAnupam Rastogi
Hi Avinash,

You need to use the Application Form Id to be stored in the Family object's College Aid Application Form field.

This will related the Family record with the Application record.

Thanks
AR

All Answers

Anupam RastogiAnupam Rastogi
Hi Avinash,

You need to use the Application Form Id to be stored in the Family object's College Aid Application Form field.

This will related the Family record with the Application record.

Thanks
AR
This was selected as the best answer
AVINASH UPADHYAAVINASH UPADHYA
Thanks guys for very informative responses!

I am facing one more issue.
In 1st page i am sending the Application ID to Family Detail page using the below code.
PageReference FamilyPage1 = Page.FamilyDetail;
FamilyPage1.getParameters().put('PageId' , ClgAppForm.Id);
             return FamilyPage1;

And I am trying to read this ID in Family Detail Page extender class using the below code.
public class FamilyDetailExtender {
    Public final Id PageId{get;set;}
Private final Family_Member_Details__c FamilyDetail;
    Public FamilyDetailExtender(Apexpages.StandardController Fmly){
    FamilyDetail = (Family_Member_Details__c)Fmly.getRecord();
        PageId = ApexPages.currentPage().getParameters().get('PageId');
         
        system.debug('------------------------------->'+ ApexPages.currentPage().getParameters().get('PageId'));
FamilyDetail.College_Aid_Application_Form__c = [select Name from College_Aid_Application_Form__c where Id = :PageId LIMIT 1].Name;
    }
}

But below code returning null value. Any idea where i am going wrong here.
ApexPages.currentPage().getParameters().get('PageId'));

Thanks once again for spending time to respond for my queries :)
AVINASH UPADHYAAVINASH UPADHYA
Just to test my program execution i hardocded the ID from Application form page in SOQL as bellow.
FamilyDetail.Application_Form__c  = [select Id,Name from College_Aid_Application_Form__c where Id = 'a1An0000000DaRBEA0' LIMIT 1].Name;

Where Application_Form__c is the custome relationship name (Master Detail). When i execute its getting error msg asl below
Visualforce Error
Help for this Page

System.StringException: Invalid id: CA-0029 
Class.FamilyDetailExtender.<init>: line 9, column 1

Please suggest me what is wrong in the above SOQL?
 
AVINASH UPADHYAAVINASH UPADHYA
Guys my last question got resolved. Please help me with 
ApexPages.currentPage().getParameters().get('PageId'));

question :)
Anupam RastogiAnupam Rastogi
Hi Avinash,

Try using this statement instead of the existing one to retrieve the PageId.
 
PageId = System.currentPagereference().getParameters().get('PageId');

Thanks
AR

If this solves your problem then please mark it as best answer.
Anupam RastogiAnupam Rastogi
Hi Avinash,

Did your issue got resolved?

AR
AVINASH UPADHYAAVINASH UPADHYA
Thank you so much Anupam. My problem got solved.

But one small doubt here, When we need to use 
ApexPages.currentPage().getParameters().get()

and when we need to use 
System.currentPagereference().getParameters().get('PageId');

When i googled as "how to get the parameter from URL in VF it gave me the 1st answer! So.. Could you please give some info on this too. Thanks again for giving your precious time for solving my query. :)