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
MRutterMRutter 

Create a New Task with Record Type

I am attempting to use an s-control to create a new event (easy enough), but want it to apply to a specific record type.  The following is the code I have tried:
 
<script type="text/javascript">
window.parent.location.href="{!URLFOR($Action.Activity.NewEvent,null,
[retURL=URLFOR( $Action.Contact.View, Contact.Id)]
)} &recordtype='01280000000EpvVAAS'";
</script>
 
This allows me to create a new event, but the default record type is used instead of the one specified in the code.  How do I make this work?
 
Mark
Best Answer chosen by Admin (Salesforce Developers) 
MRutterMRutter

I now have this s-Control working as desired.  My code is:

 

<script type="text/javascript">

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

</script>

 

Note also what I needed to do to fill in custom fields (ids with leading zeros) for lead.name and contact.name.  If you try to pass these inside the [] brackets you get a 'Missing Name' syntax error.

 

Hope this helps.

All Answers

Greg HGreg H

Try passing the recordtype parameter in the URLFOR function like your returl parameter is being passed.

-greg

dmchengdmcheng

I have a similar problem except I keep getting prompted for the record type even though I've specified it in the URLFOR.

 

 

 

<script type="text/javascript">
window.parent.location.href="{!URLFOR($Action.Investment_Task__c.New,null,
[retURL=URLFOR($Action.Tranche_Release__c.View, Tranche_Release__c.Id), recordtype='01280000000EpvVAAS'])}";
</script>

 

Message Edited by dmcheng on 03-03-2009 04:13 AM
Message Edited by dmcheng on 03-03-2009 06:22 PM
MRutterMRutter

I now have this s-Control working as desired.  My code is:

 

<script type="text/javascript">

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

</script>

 

Note also what I needed to do to fill in custom fields (ids with leading zeros) for lead.name and contact.name.  If you try to pass these inside the [] brackets you get a 'Missing Name' syntax error.

 

Hope this helps.

This was selected as the best answer
CYBURTCYBURT

Hello,

 

I have a similar problem that I am trying to solve, but I was wondering if this could be solved without using an S-Control? I'm new to Salesforce so I have heeded all the warnings so far about S-Controls becoming obsolete and avoided them, therefore my experience with them is very limited.   Here is what I am trying to do:  I have created several Account record types (Customer, Vendor, Subcontractor). Each will have their own Account Detail layout. The requirement is to have a separate tab for each of these that contains a list of accounts/contacts along with a button that allows the creation of that specific type.  For example, the Customer Account tab would have a "New Customer Account" button, that ideally, when clicked, would bring the user to the Customer Account detail page layout and allow them to create a new account with a record type "Customer Account", bypassing the record type selection page.   I included my code below (VisualForce page and controller extension).   Is there a way to incorporate your solution above into my Command Button logic (in RED)?  If  S-Control is the only way to accomplish this, I have no problem using one, I just don't know how to work it into a custom page like this.  

 

Thanks in advance for your help!

 

<apex:page standardcontroller="Account" tabstyle="Customer_Accounts__tab" extensions="CustomerAccountListExtension">
<apex:form >
    <apex:pageBlock title="Customer Accounts">
    <apex:pageBlockButtons >
      <apex:commandbutton value="New Customer Account" action="{!URLFOR($Action.Account.New,null,[RecordType='01280000000FuUp',Type='Account'])}"/>   

</apex:pageBlockButtons>
    <apex:pageBlockTable value="{!CustomerAccounts}" var="a">
      <apex:column headerValue="Customer Account">
          <apex:outputLink value="/{!a.account.Id}" target="_parent">{!a.Account.Name}</apex:outputLink>
      </apex:column>
      <apex:column headerValue="Contact Name">
          <apex:outputLink value="/{!a.Id}" target="_parent">{!a.Name}</apex:outputLink>
      </apex:column>
      <apex:column value="{!a.phone}" headerValue="Work Phone"/>
      <apex:column value="{!a.mobilephone}" headerValue="Mobile Phone"/>
    </apex:pageBlockTable>
  </apex:pageBlock>
</apex:form>
</apex:page>

 

public class CustomerAccountListExtension {

 

    public CustomerAccountListExtension(ApexPages.StandardController controller) {
    }

 

    public List<Contact> getCustomerAccounts() {

        return
        [SELECT
         ID,
         Name,
         Phone,
         MobilePhone,
         Account.name
         FROM Contact
         WHERE Account.RecordType.Name = 'Customer Account'];

    }

}

 

 

MRutterMRutter

Cyburt,

 

I do not know how to specify the record type in a Visual Force Page, or in APEX.  Hopefully someone knows and will respond.

 

Mark

Dogen ZenjiDogen Zenji

Have you tried using the onclick attribute instead of action on the commandButton?  As far as I know, the action attribute should only be used for binding to an Apex controller method.  Try this instead...

 

<apex:commandbutton value="New Customer Account" onclick="window.parent.location.href='{!URLFOR($Action.Account.New,null,[RecordType='01280000000FuUp',Type='Account'])}';"/>

 

 

 

Message Edited by Dogen Zenji on 10-29-2009 06:10 PM
Message Edited by Dogen Zenji on 10-29-2009 06:11 PM
MRutterMRutter

Thanks for the tip.  The following seems to working for me.  I wanted to re-work an S-Control that allowed the user to schedule a new event (a Tour) for contacts.  I put this VF code under a custon button.

 

<apex:page standardController="Contact"> <h1>YOU HAVE ELECTED TO SCHEDULE A NEW TOUR</h1> <apex:form > <apex:commandButton value="Continue" onclick="window.parent.location.href='{!URLFOR($Action.Activity.NewEvent,null, [who_id=Contact.Id,retURL=URLFOR( $Action.Contact.View, Contact.Id)],true )} &00N80000002rqFh={!Contact.Name}&RecordType=01280000000EpvV&type=Event&setupid=EventRecords';" /> </apex:form> </apex:page>