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
Hero285LinkHero285Link 

About the Relationships.

Hi everybody, Im a little confused about relationships,  http://imageshack.us/f/850/0j4e.png/    this is my schema model, 

Contact(they are my employes), Accounts(they Are my enterprises), Servicio(they are my pack of services every pack contains some products), EmpresaServicio(they are Are my relationships betwen Accounts,and Servicio), Producto( they Are my products), And ServicioProducto(they are the relationship betwen Servicio and producto),

So i been working with a visual force page,, my idea is: My Account get some Services, and Contact can Acces only to the Services of his Account, and it will be able to see what products contain that service, 

but i dont know how,,  y cant see the services on my Contac perspective, i want to be able to acces to the products too,,

 

 

This is my controller

 

public Contact miContacto{get;set;}
public Account miEmpresa{get;set;}

public ClienteServicioController(){
miContacto=[Select id,Name,RFC__c,Edad__c,Sexo__c, Contact.Account.Name
From Contact
WHERE Id = :ApexPages.currentPage().getParameters().get('id')];

miEmpresa=[Select id,Name,RFC__c,
(Select id,Name,RFC__c,Edad__c,Sexo__c From Contacts
WHERE Id = :ApexPages.currentPage().getParameters().get('id')),
(Select Account__c, Servicio__c, Servicio__r.PrecioServicio__c,Servicio__r.Name from EmpresasServicios__r)
from Account ];
}

 

 My apex page URL Contain the Contac ID.

 

 

<apex:repeat var="client" value="{!miContacto}" >
<h2><span>Servicios <strong>DISPONIBLES</strong> para {!client.Name}</span></h2>
</apex:repeat>
<div id="items">


<apex:repeat var="prueba" value="{!miEmpresa.EmpresasServicios__r}" >
<h2><span>Servicios <strong>DISPONIBLES</strong> para {!prueba.Servicio__r.Name}</span></h2>
</apex:repeat>

 

Im trying to get the Services based on my Contact ID

I hope you can help me,, im confused.

 

Thank you All

sandeep@Salesforcesandeep@Salesforce

When it comes to solving by VF page then you need to show any hide data as  per some conditions and these conditions will be built in controller side.

 

2nd Way is using sharing setting and sharing rule

Hero285LinkHero285Link

Thanks For Answering my post, 
My data is visible, My problem i think is my query,  because, i want to filter information, but it shows me all the info aviable 

My Actual query goes like this:

miEmpresa=[Select ID, Name,RFC__c,
(Select ID, Name,RFC__c,Edad__c,Sexo__c From Contacts 
Where Id =: ApexPages.currentPage().getParameters().get('id')),
(Select Name,Account__c, Servicio__c, Servicio__r.PrecioServicio__c,Servicio__r.Name from EmpresasServicios__r )
from Account Where Id IN (Select Account__c From EmpresaServicio__c) ];


and im showing this 

<apex:repeat var="enterprice" value="{!miEmpresa}" >
<p>Servicios  {!enterprice.Name}  for  {!enterprice.EmpresasServicios__r}</p>
</apex:repeat>

 

but it shows me all the {!enterprice.Name} and all the {!enterprice.EmpresasServicios__r} ,,
i just want to see the {!enterprice.Name}  and the  {!enterprice.EmpresasServicios__r}  who are related to my Contac Id, which is in the page Url.

i hope im clear,, thank you so much! =D