Skip to main content
Skip table of contents

Example: Adding a roll call to a page

If you would like to return a Roll Call of participants of an Advocacy action, you can use the following HTML code.

JS
<script> $(function() {
	var dataUrl = 'https://page.subdomain.org/ea-dataservice/data.service?service=FundraisingRollCall&token=xxxxxx-xxxxx-xxxxx-xxxxxxxxx&campaignId=yyyy&dataSet=2&contentType=json';
	var count = 10;
	executeRollCall(dataUrl, count);
}); </script>

<script>
    async function executeRollCall(dataUrl,display){
	
	if(!dataUrl){
		console.log('No data url passed');
		return false;
	}
	if(!display || display == 0 || display % 1 !== 0){
		display = 5;
	}
	try {

		let response = await fetch(dataUrl, { mode: 'cors'})
		let result = await response.json()

		result.rows.reverse();

		var wrap = $('#rollCall');

		var count = result.rows.length;

		for(var i=0; i<count; i++){
			
			var name = $.trim(result.rows[i].columns[0].value);
			var country = $.trim(result.rows[i].columns[1].value);
			
			if(i < display){
				var row = '<div style="display:block;" class="row" >' + name + ' ' + country + '</div>';
			}else{
				var row = '<div style="display:none;" class="row" >' + name + ' ' + country + '</div>';
			}
			wrap.append(row);
		}
	}
	catch(err){
		console.log('Unable to load roll call data:', err)
	}	
}
</script>

<div id="rollCall">&nbsp;</div>

Place this on your page where you would like the RollCall to appear.

You’ll need to replace:

var dataUrl = ‘https://page.subdomain.org with domain/ subdomain of the page where you’re placing the call

xxxxxx-xxxxx-xxxxx-xxxxxxxxx with your own public token

yyyyyy with your campaign ID.

Campaign ID is not the same as Page ID. You can find it by right clicking on the Page > select View Source > Scroll to the bottom of the page > Look under </html> tag for content inside <!– Page NAME -0423-c3:51461:115614:10053 –>

The rows will appear in the div with the id “rollCall”.

You can control how many rows are returned by changing this section:

CODE
var count = 10;

Change 10 to the number of rows you would like to return.

You can also change what data is returned:

  • dataSet=1 will return first name and country

  • dataSet=2 will return first name and town

The page must have a jquery library in order for the script to work.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.