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
hitzhitz 

How to override Custom object URL ???

Hi,

 

I am is having one custome object Created in my application. and i have Created Tab of that object...

 

Now i have created one visual force page i want to redirect to that same object. code is below

 

<apex:outputLink value="{!URLFOR('/a08/o')}">Dispute</apex:outputLink>

 

code works good but when installed package into another production org it will give me insufficent Previliges Error. because it is changes object tab id ('/a08/o') to ('003/o') .. 

 

i want to make url fix .... is it possible ????????

 

What to do in This case ??

Help me and Reply me ASPS.

Best Answer chosen by Admin (Salesforce Developers) 
hitzhitz

hi to all i got solution 

 

using Describe Call method

 

Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();
        Schema.SObjectType disObj = gd.get(<ObjectName>);

        return 'https://'+ApexPages.currentPage().getHeaders().get('host')+'/'+dObj.getDescribe().getKeyPrefix();

 

 

All Answers

Ispita_NavatarIspita_Navatar

As you must have realized that as you install your code in another org your object id will also change, hence you need to may be modify your login a bit. May be you can have a setting custom object and in that have 2 fields:-

1. Object name

2. Id 

 

In you code you can query this object extract the necessary id and store it in a variable say ObjId

and modify your code, so that in reads as :-

 

<apex:outputLink value="{!URLFOR('/'+ {!oBjID} +'/o')}">Dispute</apex:outputLink>

 

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.

 

samarsamar

HI hitz,

Why don't you try the following code

 

<apex:outputLink value="{!URLFOR($Action.YourCustomObjectName.Tab, $ObjectType.yourCustomObjectName)}">Home</apex:outputLink>

 I think will solve your problem.

 

hitzhitz

HI Ispita_Navatar

 

Thank you for your reply I think for all object i need set the id.. 

hitzhitz

hi to all i got solution 

 

using Describe Call method

 

Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();
        Schema.SObjectType disObj = gd.get(<ObjectName>);

        return 'https://'+ApexPages.currentPage().getHeaders().get('host')+'/'+dObj.getDescribe().getKeyPrefix();

 

 

This was selected as the best answer