1

I have a variables.config file where i have all the variables and corresponding values stored like shown below:

enter image description here

This is default sitecore file : enter image description here Now i want to replace the value 1000 with the value stored in the Variables.config file Now i am trying with this: enter image description here

But this is not working.

  • did you include the the Variable.config in the Sitecore.config file? – Hishaam Namooya Sep 19 '18 at 12:19
  • 1
    Variable replacement often doesn't work that way. Sometimes you can get lucky and try this (works on pipelines)... <policy batchSize="$(otap-batch-size)" ...><Limit>$(batchSize)</Limit></policy>. – jrap Sep 19 '18 at 12:36
  • @Hishaam yeah,i can see the variable in showconfig – Dheeraj p Sep 19 '18 at 12:49
  • @jrap i tried your suggestion. It replaces attribute value but not value of the element – Dheeraj p Sep 19 '18 at 13:17
  • Then it's not supported. I have done extensive testing of the method I suggested and some elements support it, others do not. I never dug into the details as to why it sometimes works and why it doesn't other times. – jrap Sep 19 '18 at 13:19
2

It is not possible to use Sitecore config variables in this way to set replacement values. The global config variable replacement process only works on node attributes, e.g. <setting name="xyz" value="$(variable)" />. It will not work on element values, e.g. <element>$(value)</element>.

You will find some elements in the Sitecore config which appear to look like a global variables, but checking the expanded config in "/sitecore/admin/showconfig.aspx" you will note that they have not been expanded by the ConfigReader and in fact the replacements is made by the underlying code used by that process (Sitecore.Pipelines.Loader.DumpConfigurationFiles processor is a good example of this).

For the replacement of the <Limit> node, in your case you should use a regular config patch which target's this element:

<contentSearch>
  <configuration>
    <indexes>
      <index id="sitecore_web_index">
        <commitPolicyExecutor>
          <policies>
            <policy>
              <Limit>1000</Limit>
            </policy>
          </policies>
        </commitPolicyExecutor>
      </index>
    </indexes>
  </configuration>
</contentSearch>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.