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
surenhsurenh 

URLFOR and Custom Fields with Leading Zeroes

I am trying to use URLFOR() and set some parameters to default some custom fields values. The custom fields start with two leading zeroes. The S-Control syntax checker does not seem to accept any parameter name that starts with numbers. I get "Error: Syntax error. Missing field name". The whole s-control is as follows and is used to override New Opportunity functionality to default some fields. Help! I've tried changing spaces between the quotes, param names, etc.
 
<script>
window.location.href='{!URLFOR($Action.Opportunity.New, null, [  isdtp="mn", save="x",00N40000001V3eK="test" ] , true)}'
</script>
surenhsurenh

So far I've gotten this to work but it's less than ideal, since I'm hardcoding some values and expected syntax outside of URLFOR. In addition, this works fine from the New button on the Oppty home page and the New Oppty from the sidebar dropdown but does not pass the Account ID properly from the New button on the Oppty related list on the account.

<script>

var newUrl = '{!URLFOR($Action.Opportunity.New, null, [ save="x" ] , true)}'

var completeUrl = newUrl +'&00N40000001V3eK={!User.Persona__c}&00N40000001V3eP={!User.Primary_Brand__c}&00N40000001V3eF={!User.Segment__c}&00N30000000c3Y0={!User.Business_Unit_DO_NOT_EDIT__c}';

completeUrl = completeUrl + '&cancelURL=/006/o';

window.parent.location.href = completeUrl;

</script>

surenhsurenh

Got it working on the Account page, including cancelling. Added relaying of accid. This still seems kludgy.

<script>

var newUrl = '{!URLFOR($Action.Opportunity.New, null, [ save="x", accid=$Request.accid] , true)}'

var completeUrl = newUrl +'&00N40000001V3eK={!User.Persona__c}&00N40000001V3eP={!User.Primary_Brand__c}&00N40000001V3eF={!User.Segment__c}&00N30000000c3Y0={!User.Business_Unit_DO_NOT_EDIT__c}';

var cancelUrl = '&cancelURL=/';

if ("{!$Request.accid}" == "") // not coming from account page
cancelUrl += '006/o';
else
cancelUrl += '{!$Request.accid}';

completeUrl = completeUrl + cancelUrl;

window.parent.location.href = completeUrl;

</script>

surenhsurenh

Note that the save=x parameter is because record types are being used. Without it, after you select a record type, the browser just keeps coming back to the record type selection page. Just some voodoo here. Don’t really know why it works.

marie.tournemarie.tourne
save=x works great for users that have multiple record type available for an object.
In an organization that uses multiple record type for some users and one record type for others, it does not work correctly. The save=x tries to save the edit page opened for users that only have one record type available.
 
Have you ever had this problem ? (And know a solution ?)
 
Thank you
marie.tournemarie.tourne
I actually did find a solution myself .. here it is :

window.parent.location ="/006/e?nooverride=1&RecordType={!Opportunity.RecordTypeId}&<other parameters>";

This opens a new opportunity but can be adapted to any object. It works wether the user has one or several record type activated on his profile.

MRutterMRutter

I was having the same problem with the field ID for custom fields with leading zeroes.  I was also looking for a way to specify the record type for new event records.  The following s-control is working for me:

 

<script type="text/javascript">

window.parent.location.href="{!URLFOR($Action.Activity.NewEvent,null,
[retURL=URLFOR( $Action.Contact.View, Contact.Id)]
)} &00N80000002rqFh=Here&RecordType=01280000000EpvV&type=Event&setupid=EventRecords";

</script>

 

I'm new to this, so any comments are welcome. 

 

Mark