You need to sign in to do that
Don't have an account?
Prasun Banerji
How to call a managed Visual Force page from another custom Visual force page
I have a installed managed package. The package has a visual force page which is put as a button on the detailed page. The controller for the viusal force page is not defined global and hence I cannot see that code.
I also have another custom button on the list view of the same object. I would like to call the visual force page of the installed package after my own logic in the custom button (visual force page with controller).
Is there any way to do that?
Thanks,
return new PageReference('/apex/MangedVisualforcePageName');
<apex:page standardController="ECS__Product__c" extensions="SampleCheckedController" action="{!updateSampleChecked}">
<apex:pageMessages id="pageMessages" />
</apex:page>
Here is the my controller :
public class SampleCheckedController {
public ECS__Product__c objEcsProduct{get;set;}
public List<ECS__Product__c> lstEcsProduct{get;set;}
public List<ECS__Product__c> updatelstEcsProduct{get;set;}
public String getrecordId{get;set;}
public SampleCheckedController(ApexPages.StandardController controller)
{
getrecordId = ApexPages.currentPage().getParameters().get('ids');
String[] splittedECSId= getrecordId.split(',');
Set<Id> splitsids = new Set<Id>();
for(Integer i=0;i<splittedECSId.size();i++)
{
splitsids.add(splittedECSId[i]);
}
if(splitsids!=null)
{
lstEcsProduct= [select id,name,CostPriceChecked__c,ECS__Unit_Weight__c,PeopleVox__PeopleVox_Last_Updated__c,Parcel_Type__c,ECS__Length__c,Sample_Checked__c,ECS__Width__c,ECS__Height__c,ECS__EAN__c from ECS__Product__c where id In: splitsids]; // Get all records based on Splitted ids and holding them all to List
}
}
public void updateSampleChecked()
{
updatelstEcsProduct = new List<ECS__Product__c>();
for(Integer i=0;i<lstEcsProduct.size();i++)
{
if(lstEcsProduct[i].CostPriceChecked__c==true && lstEcsProduct[i].ECS__Unit_Weight__c!=null && lstEcsProduct[i].Parcel_Type__c!=null && lstEcsProduct[i].ECS__Length__c!=null && lstEcsProduct[i].ECS__Width__c!=null && lstEcsProduct[i].ECS__Height__c!=null && lstEcsProduct[i].ECS__EAN__c!=null) //checking the Fields Of ECS__Product__c Object cannot be null
{
lstEcsProduct[i].Sample_Checked__c='Yes';
lstEcsProduct[i].PeopleVox__PeopleVox_Last_Updated__c=null;
updatelstEcsProduct.add(lstEcsProduct[i]);
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.severity.CONFIRM,'Sample Checked Successfully');
ApexPages.addMessage(myMsg);
}
else
{
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.severity.ERROR,'Product Can Not Be Marked As Sample Checked. Please Make Sure All Fields Are Populated'); //Adding Error Message to be displayed on VisualForce Page
ApexPages.addMessage(myMsg);
}
}
if(updatelstEcsProduct.size()>0)
{
update updatelstEcsProduct ;
}
for(Integer i=0;i<lstEcsProduct.size();i++)
{
// This is where I must call that managed visual force page to run through all the products passing the ID one by one. The code of the visual force page
//taking only one id as its on the detailed page, and this button is on list view.
}
}
}
I am trying to call the managed VF page in the below section as commented. I hope that clarifies the issue.
to public PageReference updateSampleChecked
and at the end of the method add a return statement.
So my button is on list view which runs on the selected record, the managed vf page is on the detailed page , so it takes only one ID. How, can I loop it through all my selected records using page reference.
So you dont see any workaround to call that logic using some loop ?
Your code is using StandardController, not a StandardSetController. Can you confirm whether your code works for multiple records?
So, once I click my custom button on list view page after selecting multiple records, it must call that package VF page logic to pass those records using API to the external system.
<apex:page standardController="ECS__Product__c" extensions="PeopleVox.UpdatePVXProductsController" action="{!updatePVX}"> <apex:pageMessages id="pageMessages" />
</apex:page>