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
DesaiDesai 

Id's in URL Hacking

Hi,

To implement URL hacking, we use id's in the URL. Wanted to know if the ID's would remian same if we migrate it to different evn ? 

Regards,
Pallavi
Akash_CRMAkash_CRM
Hi Pallavai,

The custom field Id would differ from one Environment to the other (except for Production ORG and Full Copy Sandbox) there by it is not at all recommendable to use hardcoded field Id’s in the code, below are the approaches you can go for:
  1. Create a custom setting to save the Field Id and refer the custom setting value in your code, you would however need to change the custom setting value once deployed to a different environment.
  2. Using Tooling API to retrieve field Id by querying CustomField object, below are the scenarios depending on the field if part of Standard or Custom Object
  • If the Field is part of Standard Object then the Field Id can be retrieved using Tooling API by making a callout to the below Endpoint:
 
/services/data/v32.0/tooling/query?q=SELECT+Id+from+CustomField+where+DeveloperName+=+'Account'
  • If the Field is part of Custom Object then then first the Object Id needs to be retrieved using Tooling API by making a callout to the below Endpoint:
 
/services/data/v32.0/tooling/query?q=SELECT+Id+from+CustomObject+where+DeveloperName+=+'XYZ__c'
 
  • Once Object Id is retrieved the Field Id can be retrieved using Tooling API by making a callout to the below Endpoint:
 
/services/data/v32.0/tooling/query?q=SELECT+Id+from+CustomField+where+DeveloperName+=+'Custom_Object_ID'
 
Regards,
Akash
 
 
DesaiDesai
Hi Akash,

Thanks for the solutions. 
Should we create new fields to store the query output ?

Regards,
Pallavi
Akash_CRMAkash_CRM
Hi Pallavi,

You need not create a new field for the same, you need to handle the entire thing in Code and hold the Id in a Variable which can be used in the URL being framed.

Please reply for any further clarifications or mark the above reply if it has addressed your concern. 

Regards,
Akash.