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
Ben4817Ben4817 

Problem using Account.PersonContactId in S-Control

I have an s-control for a contact that needs to grab related objects.  It works great on Contacts, but I need it to work on Person Accounts as well.  The API states that the contact Id for the Person Account is stored in the Account.PersonContactId field, but the s-control says that field does not exist.  I need the following to work:

 

var result = sforce.connection.query("Select Id, Name from CustomObject__c where Contact__c = '"+"{!Account.PersonContactId}"' ");

 

I've tried using the account id as was suggested in another thread, but that did not work.  Any help would be appreciated.  Thanks! 

Best Answer chosen by Admin (Salesforce Developers) 
Ben4817Ben4817

I actually got this to work myself.  I ended up doing a query to get all contacts with the account Id of the person account I needed to work with.  It looks like this now:

 

if("{!Account.IsPersonAccount}"==1) {
   var tempresult = sforce.connection.query("Select Id, Name from Contact where AccountId = '"+"{!Account.Id}"+"' ");
   var contacts = tempresult.getArray("records");
   recordid = contacts[0].Id; 

}
else recordid = "{!Contact.Id}"; 

 

It still seems bizarre that I can't access the PersonContactId field because I know that it's there and has data.  Hopefully this helps someone else get around this.