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
Tom RandallTom Randall 

Button to create task but allow record type selection.

Heya, 

I am trying to create a Custom Button on the incident object that creates a Task and links it to the incident object record it came from. This was fine, see below:

{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")} 
var newtask= new sforce.SObject("BMCServiceDesk__Task__c"); 
newtask.BMCServiceDesk__taskDescription__c = "my new task"; 
newtask.BMCServiceDesk__FKIncident__c = "{!BMCServiceDesk__Incident__c.Id}"; 
var result = sforce.connection.create([newtask]); 
window.location.reload();

The issue i have is that it uses the default task record type, I would like it to bring up the select record type page. Is this possible?
 
Vishal Negandhi 16Vishal Negandhi 16
For that to happen, you'll need to redirect the user to the standard task record type selection page and in the url, add these two parameters to assign values to the fields. 

We have implemented something like this, created a new button which redirects to the below url:
/setup/ui/recordtypeselect.jsp?ent=Task&retURL=/{!Account.Id}&save_new_url=/00T/e?what_id={!Account.Id}&retURL=/{!Account.Id}&tsk5=Call

In the above url, see the bold content. 
The first part is the url for Standard Task Record type selection page. 
The end part is subject field getting defaulted to "Call". tsk5 is the id for this field. 

Similarly, you need to add ids for your two fields and add them in the url to pass values. 

Hope this helps :)