Hi,
We can get custom field ids for URL hacking to auto populate through Tooling API as shown below.
Apex Code:
List<FieldDefinition> fieldList = [SELECT
DurableId,QualifiedApiName FROM FieldDefinition WHERE
EntityDefinition.QualifiedApiName ='Account'and QualifiedApiName='NoofEmployees__c'];
String NoofEmployeesId =
fieldList[0].DurableId.split('\\.')[1];
Visualforce Page (Java Script):
<script type="text/javascript">
var __sfdcSessionId = '{!GETSESSIONID()}';
</script>
<script
src="../../soap/ajax/38.0/connection.js"
type="text/javascript"></script>
<script>
var qr =
sforce.connection.query("SELECT DurableId,QualifiedApiName FROM
FieldDefinition WHERE EntityDefinition.QualifiedApiName ='Account'and
QualifiedApiName='NoofEmployees__c'" );
var NoofEmployeesId = qr.getArray("records")[0].DurableId.split('.')[1];
</script>