Skip to content

Instantly share code, notes, and snippets.

@samteezy
Last active December 10, 2018 21:27
Show Gist options
  • Select an option

  • Save samteezy/fa580a0b742a655c64e6ccbf9c8c76de to your computer and use it in GitHub Desktop.

Select an option

Save samteezy/fa580a0b742a655c64e6ccbf9c8c76de to your computer and use it in GitHub Desktop.
Passing parameters from referer/parent VF page to iframe/child VF page
public class Object_ext{
public final Object__c ob;
public String objId {get;set;}
public String referer {get;set;}
public Project_ext(ApexPages.StandardController stdController) {
referer = ApexPages.currentPage().getHeaders().get('Referer');
System.debug(referer); //Just to check!
if(UserInfo.getUserType() != 'Standard'){ //If it's a community user,
objId = getCommId(ApexPages.currentPage().getHeaders().get('Referer')); //then we pull the value from our parameter by examining the referer,
ApexPages.currentPage().getParameters().put('id', objId); //and write that back to the page's ID parameter for the standard controller.
}
else {
objId = ApexPages.currentPage().getParameters().get('Id'); //Otherwise, for internal users, just pull down the parameter.
}
this.ob= (Object__c)stdController.getRecord();
}
public String getCommId(String referer){
String comStr = 'id=';
return referer.substring(referer.indexOf(comStr)+3, referer.indexOf(comStr)+21); //This will always be looking for an 18-digit char ID.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment