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
Vincent FruchierVincent Fruchier 

how to create a formula between saleforces objects ?

Hello,
I have a problem, I want create a formula between saleforces objects but I have an error message.
"Erreur : Le champ Questionnaires__r n'existe pas. Vérifiez l'orthographe"
IF(AND(Respect__c=Questionnaires__r.Respect__c,Respect__c= True),1,0)
My object "Questionnaires__c" is available, can you explain me ?
Thank in advance.
Best Answer chosen by Vincent Fruchier
Alain CabonAlain Cabon
Questionnaire is the child object so one opportunity can have many questionnaires?

select (select name from Questionnaires__r) from Opportunity  // the children.

... and one questionnaire has only one parent opportunity:

select Opportunity__r.Name  from Questionnaire  // one parent

All Answers

JLA.ovhJLA.ovh
Not enough information to explain the issue, I will do some assumptions
You have 2 objects, one is Questionnaires__c and another one is Respect__c
You have a lookup relationship from Questionnaires to Respect__c
You want to put a formula field on Questionnaires__c based on a field that is on Respect__c object, with a field named Respect__c (same as the object, why not)
Your formula field will be created in the context of Questionnaires__c object in the setup menu. You have to reference Respect__r.Respect__c.
Respect__r is the relationship name to your Respect__c SObject. Respect__c in this formula is the targeted field on the Respect__c SObject
Alain CabonAlain Cabon
Hello,

For custom objects, look for a pair of entries with the relationship suffix __r:​
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_relationships_parent_child.htm

If you want to identify Parent and Child Relationships, there is one technique when you want to see (almost) "all" the available API names in only one XML file.

Setup > quick search: API > click on Generate Entreprise WSDL > button: Generate and you get just one huge file in the browser with all the API names of your org.

User-added image


Verify all the elements with "__r" of your Questionnaire object in the exported entreprise WSDL.

'Questionnaires__r' or something very close (but in this exported WSDL, the found names are always sure).

 
Vincent FruchierVincent Fruchier
Hi, thanks for your response.
I want created a formula in opportunité object with the object questionnaire.

I check the wsdl, and the objects questionnaire is true.
<element name="Questionnaires__r" nillable="true" minOccurs="0" type="tns:QueryResult"/>

So why this formula IF(AND(Respect__c=Questionnaires__r.Respect__c,Respect__c= True),1,0)
doesnt work in opportunity obect ,

To anyone who will take the time to answer, thank you so much!.
Alain CabonAlain Cabon
Plural (most of the time) : <element name="Questionnaires__r" nillable="true" minOccurs="0" type="tns:QueryResult"/>

select (select name from Questionnaires__r) from Opportunity

... should work but that is not your needed formula probably.

Depuis questionnaire :

Singular: select Opportunity__r.Name  from Questionnaire

<element name="Opportunity__r" nillable="true" minOccurs="0" type="ens:Opportunity"/>

 
Alain CabonAlain Cabon
Questionnaire is the child object so one opportunity can have many questionnaires?

select (select name from Questionnaires__r) from Opportunity  // the children.

... and one questionnaire has only one parent opportunity:

select Opportunity__r.Name  from Questionnaire  // one parent
This was selected as the best answer
Vincent FruchierVincent Fruchier
Yes the opportunity can have many questionnaire.so I will use 
Opportunity__r.Name  from Questionnaire  // one parent