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:
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.
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:
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.
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:
Regards,
Akash
Thanks for the solutions.
Should we create new fields to store the query output ?
Regards,
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.