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
Chrissy Thompson 12Chrissy Thompson 12 

Resource Code to Pull Related Contacts

How would you write an apex controller for a visual forec page (communities) to reference a field, which holds a concatenation of all account id's the user has access to and the apex controller code for the VF page used this field's content when retrieving records.

This below does not work, but I don't know how to code so I am not surprised. Any thoughts?

public class NapiliCommunityController {
    @AuraEnabled
    public static User getLoggedInUser(){
        return [SELECT Id, Contact.AccountIds__c FROM User WHERE Id =: UserInfo.getUserId() LIMIT 1];
    }
}
Chrissy Thompson 12Chrissy Thompson 12
It doesn't seem to be working. I am using the following to support this, but my guess is that these don't work together. I took the information this blog and tried to tweek it to pull related contacts. Communities don't automatically pull related contacts that have been manually shared. Any suggestions? http://www.crmscience.com/single-post/2016/09/26/Dynamic-Navigation-in-Napili-Communities

({ redirectToAccount: function(component, event, helper) { var loggedInUser; var state; var navEvt; var action = component.get("c.getLoggedInUser"); action.setCallback(this, function(response) { state = response.getState(); if (state === "SUCCESS") { loggedInUser = response.getReturnValue(); navEvt = $A.get("e.force:navigateToSObject"); navEvt.setParams({ "recordId": loggedInUser.Contact.AccountId, "slideDevName": "detail" }); navEvt.fire(); } }); $A.enqueueAction(action); } })