function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RajeevlsHydRajeevlsHyd 

Pass specific id in the url from a controller class

There is custom object SO mapped to Opportunity . For every opportunity there are multiple SO .

I am displaying all the SO of an opportunity in an VF page and want to add attachements againgst specific SO records.

 

Controlelr class :

 

Inside COntroller Method - Adding the list in a wrapper

 

SOL = new List<SO__c>([select Id, Processing_Region__c, Company_Code__c, Opportunity__c, Account__c,Company_Name__c,Start_Date__c,Promo_Flyer__c,Parent_Company_Code__c,Pays__c from SO__c where Opportunity__c =: oppID]);

for(SO__c s :SOL)
{
SOWrap sw = new SOWrap();
sw.ProcessingRegion = s.Processing_Region__c;
sw.ParentCoCode = s.Parent_Company_Code__c;
sw.CompanyCode = s.Company_Code__c;
sw.CompanyName = s.Company_Name__c;
sw.Pays = s.Pays__c;
sw.SOID = s.Id;
wrapper.add(sw);
}

 

//Wrapper class inside the controller class

public class SOWrap
{
public String ProcessingRegion {get;set;}
Public String ParentCoCode{get;set;}
Public String CompanyCode{get;set;}
Public String CompanyName{get;set;}
Public Decimal Pays {get;set;}
Public String Product{get;set;}
public string SOID{get;set;}
}

 

On Click on add button on the VF page ...it calls the method upload from the controller :

 

public page reference upload()
{
Id oppId = ApexPages.CurrentPage().getParameters().get('OpId');
PageReference pr = new pagereference('/apex/DocumentUploader?OpId=' +oppId );
return pr;
}

 

Instead of opportunity ID i want to pass the specific SO id.. so that i can use it in next vf page ..

 

Any suggestions?

 

digamber.prasaddigamber.prasad

Hi,

 

Since you already have all related SO record in your wrapper. You can access any desired element based upon your business objective and pass the same in URL. Something like:-

 

public page reference upload()
{
    //Id oppId = ApexPages.CurrentPage().getParameters().get('OpId');

    Id soId = wrapper[0].SOID;  //you need to write code as per your business objective here
    PageReference pr = new pagereference('/apex/DocumentUploader?soId=' +soId );
    return pr;
}

 

Hope it will help you. Let me know if you have any question around it.

 

Regards,

Digamber Prasad

 

 

RajeevlsHydRajeevlsHyd

This I am able to acheive , the point where I am stuck is when I want to redirect back from the the page , I want to pass OppId as parameter.. but this is giving as null.

If I have to use only the SO id , then I am fine, but here I have to use both the id's .

 

Thanks for replying

digamber.prasaddigamber.prasad

Hi, 

 

I think to achieve this you may need to have your upload method something like:-

 

public page reference upload()
{
    Id oppId = ApexPages.CurrentPage().getParameters().get('OpId');
    Id soId = wrapper[0].SOID;  //you need to write code as per your business objective here
    PageReference pr = new pagereference('/apex/DocumentUploader?soId=' +soId + '&oppId=' + oppId);
    return pr;
}

 

Hope it will help you.

 

Happy to help you!

 

Regards,

Digamber Prasad