1

enter image description here

I figure it out when I click on the PB-005426 ({!p.Id}), to redirect to a new VF page layout (gibco2) with all vlues. But I have 5 different record type and VF pages. When user click on product brief number ({!p.Id}), I want to direct them to the right page. For Ex.

Record Type (RecordTypeId) = Media and Buffers then direct them to ('/apex/gibcopb2')
Record Type (RecordTypeId) = Hardware - S.U.B.then direct them to ('/apex/sum1')
Record Type (RecordTypeId) = BPC then direct them to ('/apex/page1')

In below code it only goes to one page('/apex/gibco2). I search for a example and could not find anything suitable for me. Most of them are confusing, and any idea how to assign multiple page according record type ID? Thanks.

<apex:page standardController="Product_Brief__c" extensions="DispatcherContactNewController">
</apex:pageBlock>
    </apex:form>
        <apex:pageBlock title="Recent Product Briefs">
            <apex:pageBlockTable value="{!pbs}" var="p" >
                <apex:column >
                    <apex:commandLink action="{! assetClicked}" value="{!P.Name}" id="theCommandLink"> 
                    <apex:param value="{!P.Id}" name="{!P.Id}" assignTo="{!selectedAsset}" ></apex:param>
                    </apex:commandLink>
                 </apex:column>
                 <apex:column value="{!p.RecordTypeId}"/>
            </apex:pageBlockTable> 
        </apex:pageBlock
    </apex:form>
</apex:pageBlock>

Extension

public class DispatcherContactNewController {

public DispatcherContactNewController(ApexPages.StandardController controller) {
            this.controller = controller;
        }

public ApexPages.StandardSetController setpb{
        get{
            if(setpb == null){
                setpb = new ApexPages.StandardSetController(Database.getQueryLocator(
                    [SELECT Id, Name, RecordTypeId, Createddate FROM Product_Brief__c ORDER BY Createddate DESC ]));
                         setpb.setPageSize(10);
                         }
                         return setpb;
           } 
           set;
    }

    public List<Product_Brief__c>getpbs(){
        return (List<Product_Brief__c>)setpb.getrecords();
    }


public string selectedAsset {get;set;}
    public PageReference assetClicked(){ 

    PageReference redirect = new PageReference('/apex/gibcopb2'); 

    // pass the selected asset ID to the new page
    redirect.getParameters().put('id',selectedAsset); 
    redirect.setRedirect(true); 

    return redirect;
    }
}
  • I think your answer is in your question. If you got this far simply follow through on the logic in your question with your code using If. then. else etc – Eric Jul 9 '15 at 2:16
1

I think if you use "If..else" to should suffice.

1) Create a map of RecordtypeId and VF Page Name ( 'MapRecTypeVF')

2) When this method is called , check the recordtypeid of the record and do this:

PageReference redirect = new PageReference('/apex/'+ MapRecTypeVF.get(RecordtyepId)); 

    // pass the selected asset ID to the new page
    redirect.getParameters().put('id',selectedAsset); 
    redirect.setRedirect(true); 
return redirect;
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.