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
FdeBergeyckFdeBergeyck 

use a variable in a URLFOR String

hello,
 
I have a problem with the overriding of a new button, and was hoping that somebody could help me. When the user clicks on the new button, two fields (Dossier which is a lookup field to the account to which the object is linked and Affaire which is a text field) must be filled in automaticaly. I have done that by using the following code:
 
window.parent.location.href="{!URLFOR($Action.Note_Private__c.New, null, [CF00N20000001IEwa = Note_Private__c.Account__c, Name = $User.Affaire__c, saveURL=URLFOR($Request.retURL, null,null,true), retURL=URLFOR($Request.retURL, null,null,true), cancelURL=URLFOR($Request.retURL, null,null,true) ], true)}";
 
Where CF00N20000001IEwa is the name of the field Dossier, and Name is the name of the field Affaire. The two fields are filled in when a user clicks on new, but the field Dossier is not filled with the right entry: Note_Private__c.Account__c returns a concatenation of the title, the first name, and the last name (ex: Mrs Marijke de Wit), but not the name of the account. My question is then, is there a way to use a variable in the URLFOR string? Something like ...CF00N20000001IEwa ="+Account+"... ? Or is there another way to fill in that field? I have access to the the Id of the account with Note_Private__c.AccountId__c, but if I put that in the URLFOR string, it will fill the field with the Id, but it will not make a link with the right account.
 
I hope this makes sense...
 
Thank you very much for your time!
 
François
pwillpwill
I have tried on several occasions to variables (declared and set in advance a' la common JavaScript) into URLFOR() with no success whatever. I am also interested in understanding this issue. Would be kind of Saleforce to let us know definitively whether it is allowed, or not allowed (and perhaps even update the user guide to say "don't bother").