You need to sign in to do that
Don't have an account?
surenh
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>
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>
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>
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.
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.
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