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
VSN_ForceVSN_Force 

access field values from java script

Hello All,

 

I am writing a java script for a button on Opportunity Obj. I want to perform some action based on the value of the record type selected for the particular record, how can i fetch that value?

 

example:

 

if(Opportunity.RecordType = 'Type1') {

alert('opportunity rec type is Type 1');

}

 

but i am not able to perform this. Please help me.

 

Thanks.

 

~VSN

Best Answer chosen by Admin (Salesforce Developers) 
vhanson222vhanson222

try something like:

 

if ("{!$RecordType.Name}" == "Type 1") 
{
    alert("Opportunity record type is 1");
}

 

 

hope that helps

 

-Victor

All Answers

vhanson222vhanson222

try something like:

 

if ("{!$RecordType.Name}" == "Type 1") 
{
    alert("Opportunity record type is 1");
}

 

 

hope that helps

 

-Victor

This was selected as the best answer
sfdcfoxsfdcfox

It's actually {!$RecordType.Name}, as the other one produces a record type ID value (15-character unique value), but the above post is correct.