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
Jon AtchisonJon Atchison 

Setting Record Types in S-Controls - how?

I have been able to pass data from 1 object to another via a S-Control but what I can not figure out how  to do is set the Record Type.  I do not want to set the users default to being the record type I want  as the end user will be using multiple types and  I want multiple s-controls passing data to the same object but onto different record types.

Any suggestions on how to set this in my s-control?
AMartinAMartin

Hi Jon,

I wasn't sure from your post if you did or did not want your users to have to select the record type of the object that they were about to create.  Hopefully this will help a little.  Here's an s-control that I created to pass a custom field "Customer Legal Name" from the Account record to the Contract object.  The s-control will bring the user to the point where they have to select the Contract record type they want.  The Customer legal name is populated into the contract record regardless of the record type selected.

To get the url, I started from an Account record and clicked the New button from the Contract related list.  sfdc then shows the page for me to select my Contract record type.  I copied the url of that page and edited it.

First, I replaced the sfdc account id number with the Account ID merge field {!Account.Id}.  Then I had to build the references to the information that had to be passed.  The field id "00N70000001Tgjy" is the id for the Contract Customer Legal Name field and the {!Account.Customer_Legal_Name__c} is the merge field for the Account field. 

https://na5.salesforce.com/setup/ui/recordtypeselect.jsp?ent=Contract&retURL=%2F{!Account.Id}&save_new_url=%2F800%2Fe%3FretURL%3D%252F{!Account.Id}%26accid%3D{!Account.Id}&00N70000001Tgjy={!Account.Customer_Legal_Name__c}

Hope this helps.

Aiden

 

Jon AtchisonJon Atchison
Aiden,

Actually I am looking to have the user select the record type, in some instances, and in others I want to control it.  I see what you have done with the URL s-control but I have been developing using the HTML s-control.  I am also not sure if URL is the type I want due to my desire to pass more than just the name of the account over to my new records, which is why I am using the HTML.  I desire to set the Record Type, Name (based on the account) and many custom fields all in one script.
Olof@EnectoOlof@Enecto
Hi Jon
Just like to know if You found a solution to this? I have exactly the same problem tyring to create Activities and Tasks of a certain recordtype without having the user selecting it.
Br
/Olof
Jon AtchisonJon Atchison

I did find a solution to this issue, I simply set the Record Type ID in my s-control.

I used a line just like below to set the value at record creation, that is just the line to set that value.  Switch out the word Policy as that was my object name.

//newPolicy.RecordTypeId = "Record Type ID goes here";

Hope that helps.