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
Div403Div403 

Having problem while passing custom field values to onclick javascript button?

Hi All,

I am unable to pass the custom field values to the below alert box. My scenario is like when i click on the custom button, i need to pass item_id__c via url to open the visual page. 

var Account = "{!Account.Id}";
var AccountName = "{!Account.Name}";
var ItemName= "{!Account.Item_ID__c}";
if(Account!=null)
{
alert('Account'+ItemName);
window.open('https://www.google.com?item='+ItemName);
}
Apurva Dutta 8Apurva Dutta 8
Hi Div403,

I assume you are trying to pass the Id for Item_ID__c in the URL. if so,you will have to use merge field. Like, OppID={!Opportunity.Id}. 

So, in your case, it would be window.open('https://www.google.com?item={!itemName}');

Hope this solves your issue. :)

Hit Kudos id this the correct asnwer. 

 
Div403Div403
Hi Apurva,

Thanks for the response.

I didn't understand why you mentioned OppID={!Opportunity.Id}. Item_Id__c is a custom field in account and it is not linked with opportunities.
 
Dushyant SonwarDushyant Sonwar
<script>
var Account = "{!Account.Id}";
var AccountName = "{!Account.Name}";
var ItemName= "test";
if(Account!=null || Account!='')
{
alert('Account'+ItemName);
window.open('https://www.google.com?item='+ItemName);
}
</script>
I tweaked your script
Try this one....
Div403Div403
Hi Dushyant,

Thanks for your response.
In my case i need to pass dynamic values to ItemName.