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
PXForcePXForce 

AccountId on Contact

How do I include AccountId (lookup field on Contact) from mergefields in my javascript onclick code for a button.

AvromAvrom

This works for me:

 

 

<apex:page standardController="contact">
  <apex:form >
    <apex:commandButton onclick="foo(); return false;"/>
  </apex:form>
  <script>
    function foo() {
      alert('{!contact.accountId}');
    }
  </script>
</apex:page>

 

 

PXForcePXForce

but i cant pick the 'accountId' from the merge fields while writing the onclick javascript on a button.How would I pick that.

AvromAvrom

Sorry, maybe I don't understand what it is you need. The example above picks out the accountId value. It doesn't actually do it inside the onclick handler; it does it in a Javascript function the onclick handler calls. But the effect is just as if you had the alert line (with merge field value) directly in the onclick handler.

 

Is it that you're trying to do this inside an iteration?