You need to sign in to do that
Don't have an account?
Den1
Override New button on Case when user has multiple record types
We have an s-control to override the New button on the Case to pass in some default values from the user record.
It works fine, unless...
the user has multiple record types and they do not want to select the default record type.
ie. user is presented with the select record type page on clicking New
Selects a record type that is NOT the default one
The default loads anyway
The url shows 2 record type ids, first the selected one and then the default one. The default takes precedence.
The field to be updated and values are on both record types.
Any ideas?
Hope following code will help u for that.
<html>
<head>
<script>
var userSegment = escape("{!User.Segment__c}");
function new_URL()
{
var url = parent.location.href; //URL accessing sControl
var completeUrl = url + '&00N40000001V3eF='+userSegment;
completeUrl += "&nooverride=1"; //pass nooverride parameter to prevent infinite reloading of new opp page
parent.location.href = completeUrl; //pass full URL to page (refresh)
}
</script>
</head>
<body onload="new_URL()">
</body>
</html>
All Answers
To pass information through the record type selection you would need to use the following base for the formula. Your field values will need to be placed after the save_new_url value. By using the link below it will take your users to the Opportunity's record type selection page.
var userRegion = escape("{!User.User_Region__c}");
newUrl = '/setup/ui/recordtypeselect.jsp?ent=Case&retURL=%2F500%2Fo&save_new_url=%2F500%2Fe';
var completeUrl = newUrl + '?retURL=%2F500%2Fo&cancelURL=%2F500%2Fo&ent=Case&00N30000000crel='+userRegion;
window.parent.location.href = completeUrl;
</script>
Above S-control code work fine for custom new button but for default new button, I stuck with infinite loop on recordType select page.
Any Idea?
Do I need to add any more parameter? Please guide
var completeUrl =newUrl+'&00N30000000bbb='+userRegion;
if ("{!$Request.def_contact_id}" != "")
completeUrl += '&def_contact_id={!$Request.def_contact_id}';
if ("{!$Request.def_account_id}" != "")
completeUrl += '&def_account_id={!$Request.def_account_id}';
if ("{!$Request.def_asset_id}" != "")
completeUrl += '&def_asset_id={!$Request.def_asset_id}';
if ("{!$Request.cancelURL}" != "")
completeUrl += '&cancelURL={!$Request.cancelURL}';
var saveX = "";
if ("{!$Request.RecordType}" != "") // there is a record type param in URL
saveX = "&save=x";
if ("{!$Request.cancelURL}" != "") {
completeUrl += '&cancelURL={!$Request.cancelURL}';
} else {
completeUrl += '&cancelURL=/500/o';
}
// put together the final URL
completeUrl += saveX;
window.parent.location.href = completeUrl;
if ("{!$Request.RecordType}" != "") // there is a record type param in URL
saveX = "&save=x";
Following is more generalize code
<script>
var completeUrl = '{!URLFOR( $Action.Case.NewCase , null, null, true)}';
completeUrl += '&cancelURL={!$Request.cancelURL}&RecordType={!$Request.RecordType}';
window.parent.location.href = completeUrl;
</script>
Still it display recordType section page twice. any idea?
Hope following code will help u for that.
<html>
<head>
<script>
var userSegment = escape("{!User.Segment__c}");
function new_URL()
{
var url = parent.location.href; //URL accessing sControl
var completeUrl = url + '&00N40000001V3eF='+userSegment;
completeUrl += "&nooverride=1"; //pass nooverride parameter to prevent infinite reloading of new opp page
parent.location.href = completeUrl; //pass full URL to page (refresh)
}
</script>
</head>
<body onload="new_URL()">
</body>
</html>
What excactly is the "Segment__c" field on the User object?
What I need is creating a new product (product has multiple recordtypes) where the name has already a standard value. The user should be able to choose the recordtype as usual.
With this url the recordtype must be chosen twice:
window.parent.location.href = "{!URLFOR($Action.Product2.Add, null, [Name = 'my default value', retURL = '/%2Fhome%2Fhome.jsp'], true)}";
Segment__C is my custom field. It's just for example. In your case it's name field.
try to override field value in form load event as shown in my previous scrap.
Hi,
What if we need to show the selected recordtype's value in a custom text box on the same field?
yes :) , I understand that it is shown on the page but users want to have that populated as part of the custom text box. I have used the sample code shown on this thread and I am able to show the values for account object on the related custom objects (having multiple recordtypes) successfully through the URL way. But now I want to have the recordtype value populated too. Please guide me.
Thanks
Dcoder
Pagereference newPage = new Pagereference(pageurl); newPage.getParameters().put(IPropertyNames.NO_OVERRIDE, IPropertyNames.ONE); newPage.getParameters().put(IPropertyNames.RETURN_URL,ApexPages.currentPage().getParameters().get(IPropertyNames.RETURN_URL)); newPage.getParameters().put(IPropertyNames.CONFIRMATION_TOKEN,ApexPages.currentPage().getParameters().get(IPropertyNames.CONFIRMATION_TOKEN)); newPage.getParameters().put(IPropertyNames.CANCEL_URL,ApexPages.currentPage().getParameters().get(IPropertyNames.CANCEL_URL)); newPage.getParameters().put(IPropertyNames.ENT,ApexPages.currentPage().getParameters().get(IPropertyNames.ENT)); String recordType = ApexPages.currentPage().getParameters().get(IPropertyNames.RECORDTYPE); if(recordType != null) { newPage.getParameters().put(IPropertyNames.RECORDTYPE,recordType); }return newPage;
https://developer.salesforce.com/forums/ForumsMain?id=906F0000000kAtSIAU
Thanks!