+1
Answered

Assigning a source to a datasource

Richard Lindley 12 years ago updated by icahill (Administrator) 12 years ago 1
If I assign a source to a datasource when I define the datasource, it works. If I leave out the source and assign it in an action, it doesn't seem to work. Is there a standard method of loading datasources?

This works:

<datasources>
<datasource name="RSSFeed" source="http://defensesystems.com/rss-feeds/all.aspx" query="//item" providertype="xml" parsenamespaces="yes" />
</datasources>

<action name="boot" oninit="yes">
<alert message="[datasource:RSSFeed.dataSourceResultCount]"></alert>
</action>


This doesn't:

<datasources>
<datasource name="RSSFeed" source="" query="//item" providertype="xml" parsenamespaces="yes" />
</datasources>

<action name="boot" oninit="yes">
<assign property="datasource:RSSFeed.source" value="http://defensesystems.com/rss-feeds/all.aspx" />
<alert message="[datasource:RSSFeed.dataSourceResultCount]"></alert>
</action>
This is happening because you are assigning the datasource and the alert oninit. The system is trying to kick off both actions at the same time. Usually if you are assigning a datasource oninit you might as well just put the source in your datasource tag.

If you want to keep it like this, try putting the assign and alert in a sync block, so they will run in order.