Answers.Body: <p>Well, when I went properly through the output of <code>{{ dump(company.businessName) }}</code> I found out right from the start that it is element criteria model of entry type.
  That led me to check for the <code>handle</code> <code>company</code> that could exists twice in system.</p>
  
  <p>I found section with the <code>handle</code> <code>company</code>. So two identical handles in system were causing my problem. But on the first place, how could Craft let me save the global set with the <code>handle</code> that already existed in system even if they are different type of element criteria model and Craft would throw that string conversion error anyway?</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-07T18:09:21.723Z
Answers.LastActivityDate: 2018-11-07T18:51:31.677Z
Answers.LastEditDate: 2018-11-07T18:51:31.677Z
Answers.UserDisplayName: Dominik Krulak
Body: <p>I've been using globals many times but this is my first time encounter with such problem. Let's go from the bottom. I have two global sets with handles <code>tax</code> and <code>company</code>. The Tax set have only one plain text field <code>taxRate</code> which can be accessed like <a href="https://docs.craftcms.com/v2/globals.html#templating" rel="nofollow noreferrer">documentation</a> says <code>{{ tax.taxRate }}</code>.</p>
  
  <p>The Company set have more plain text fields and one table field.
  Odd thing happens when I try to access any plain text field the same way. Example: <code>{{ company.businessName }}</code>.</p>
  
  <p>I've tried to see what I get outputted using <a href="https://twig.symfony.com/doc/2.x/functions/dump.html" rel="nofollow noreferrer">dump()</a> function of that field and the output is quiet broader than the dump output of <code>{{ tax.taxRate }}</code>.</p>
  
  <pre><code>{{ dump(tax.taxRate) }}` -&gt; string(2) "20"
  
  {{ dump(company.businessName) }}` -&gt; object(Craft\ElementCriteriaModel)#942 (17) {
  ["strictAttributes":protected]=&amp;gt;
  bool(false)
  ["_elementType":"Craft\ElementCriteriaModel":private]=&amp;gt;
  object(Craft\EntryElementType)#372 (7) {
  ["componentType":protected]=&amp;gt;
  string(11) "ElementType"
  ["_sourcesByContext":"Craft\BaseElementType":private]=&amp;gt;
  NULL
  ["_classHandle":"Craft\BaseComponentType":private]=&amp;gt;
  NULL ... and another dozens lines of it
  </code></pre>
  
  <p>I can access it using <code>craft.globals.getSetByHandle('company')</code> but I don't understand why I'm getting <strong>object</strong> returned in the set Company and <strong>string</strong> returned in the set Tax using the same fetch approach? </p>
  
Tags: <globals><craft2>
Title: Accessing global set's field gives object that couldn't be converted to string
ThreadText: # Accessing global set's field gives object that couldn't be converted to string
  
  (Asked by: username_0 on 2018-11-07)
  
  I've been using globals many times but this is my first time encounter with such problem. Let's go from the bottom. I have two global sets with handles `tax` and `company`. The Tax set have only one plain text field `taxRate` which can be accessed like [documentation](https://docs.craftcms.com/v2/globals.html#templating) says `{{ tax.taxRate }}`.
  
  The Company set have more plain text fields and one table field.
  Odd thing happens when I try to access any plain text field the same way. Example: `{{ company.businessName }}`.
  
  I've tried to see what I get outputted using [dump()](https://twig.symfony.com/doc/2.x/functions/dump.html) function of that field and the output is quiet broader than the dump output of `{{ tax.taxRate }}`.
  
  ```
  {{ dump(tax.taxRate) }}` -> string(2) "20"
  
  {{ dump(company.businessName) }}` -> object(Craft\ElementCriteriaModel)#942 (17) {
  ["strictAttributes":protected]=&gt;
  bool(false)
  ["_elementType":"Craft\ElementCriteriaModel":private]=&gt;
  object(Craft\EntryElementType)#372 (7) {
  ["componentType":protected]=&gt;
  string(11) "ElementType"
  ["_sourcesByContext":"Craft\BaseElementType":private]=&gt;
  NULL
  ["_classHandle":"Craft\BaseComponentType":private]=&gt;
  NULL ... and another dozens lines of it
  
  ```
  
  I can access it using `craft.globals.getSetByHandle('company')` but I don't understand why I'm getting **object** returned in the set Company and **string** returned in the set Tax using the same fetch approach?
  
  **Tags:** globals, craft2
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2018-11-07. Score: 1
  
  Well, when I went properly through the output of `{{ dump(company.businessName) }}` I found out right from the start that it is element criteria model of entry type.
  That led me to check for the `handle` `company` that could exists twice in system.
  
  I found section with the `handle` `company`. So two identical handles in system were causing my problem. But on the first place, how could Craft let me save the global set with the `handle` that already existed in system even if they are different type of element criteria model and Craft would throw that string conversion error anyway?
  
  
  ---
  
  