+ Start a Discussion
Philippe Rapin 5Philippe Rapin 5 

Custom button to open the record in another page with another Layout

Hello,

I am trying to setup a custom button to open the current record (Case  object), but with a custom Layout (such as a printable summary).

I created the Layout (called "Case Layout - Support Report") and the button, but I do not understand how I can force the Layout.
Here is the code of the button (please indicate me a proper way, if possible, I do not like the hardcoded way:
https://eu4.salesforce.com/{!Case.Id}

Thanks for your help
Swayam@SalesforceGuySwayam@SalesforceGuy
Hi,

There are two approach to do this.

If you know what the recordtype is then hardcode in the URL.
for example  https://ap1.salesforce.com/{!Case.Id}/e?RecordType=01290000000spKa
 
The text in the red is recordtype id.

 
Another approach would be dynamic, You will have to make query to fatch recordtype.
For this you need to use content source for button is java script. Here I am sharing some code you can refer and let me know
 
{!REQUIRESCRIPT("/soap/ajax/15.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/22.0/apex.js")}
var results= sforce.connection.query("SELECT id,Name
FROM RecordType " +
"WHERE SobjectType='Contact ' AND Name='PrimaryContact'");
var records = results.getArray("records");
var arr = new Array();
var id;
for (var i = 0; i < records.length; i++)
{
id = records[0].id;

}
var url = 'yourlink or extrra&RecordType ='+id;
window.open(url,target=_blank');



Hope this helps !!

--
Thanks,
Swayam 
Philippe Rapin 5Philippe Rapin 5
Hi Swayam,

Thanks for the answer. I am not sure about the RecordType solution. The Layout I want to apply is not the standard Layout for the RecordType but another one...

The idea is when a case is terminated, it would be possible to generate a report that does not contains every fields, but only a couple of ones.

Regards