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
canonwcanonw 

Look up custom field id in form at runtime

I wonder if this is doable. I have the following code snippet in scontrol

Code:
<script language="JavaScript"> 

function refresh() {

// How to replace hard-code value with a lookup function?
var someCustomField = '00N60000001Wksv';

window.opener.location="/001/e—retURL=%2F001%2Fo&RecordType=0123000000007cT&" + someCustomField + "=2";
}

refresh();
</script>
 
Is there a function to lookup a particular custom field in a form?

Here's my siutation.  I create a custom field in sandbox.  Obviously I have to create the same field in production server.  The problem is this new custom field having different id. 
And I don't want to have source code just to keep track the id difference.
werewolfwerewolf
See what happens if you package it and install it to production.  The packaging system often replaces IDs in the source system with IDs in the target system, so that might take care of the problem for you.
ShamilShamil
Werewolf, your guess is right!
Based on POC that I made:
If an s-control is packaged and then installed into the destination org, custom fields' Ids are automatically replaced by SFDC.

However, custom fields should be created before s-control is imported.
GoForceGoGoForceGo

Werewolf,

 

I could try this, but wondering - Will the packaging code recoginze "CF" prefix?

 

As a background, in my VF page, I want to provide a link with a URLFOR($Action.CustomObject__c.New) page. I want to pass these lookup field as parameters.  I can write  CF00N70000002eKBS in the VF page, but I am not sure if they will get replaced in installing org. I cannot write 'CF' & '00N70000002eKBS' in a VF page as a left side of the parameter - VF parser does not seem to like it.

 

Or do I have to  write Apex code and use references and hope that this will get replaced in Apex code?:

 

        String auditItemLkId = 'CF' + '00N70000002eKBS' + '_lkid'; 
String auditItemName = 'CF' + '00N70000002eKBS';