Query issues

To find a specific issue, you can use the
NEW TO SITEFINITY?
NewslettersManager.  The following code finds all issues per campaign with the specified rootCampaignId through the Native API.

Figure 1: GetIssues by rootCampaignId.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Telerik.Sitefinity.Modules.Newsletters;
using Telerik.Sitefinity.Newsletters.Model;
namespace Telerik.Sitefinity.Documentation.CodeSnippets.DevGuide.SitefinityEssentials.Modules.EmailCampaigns
{
public partial class EmailCampaignsSnippets
{
public static IQueryable<Campaign> GetIssues(Guid rootCampaignId)
{
NewslettersManager manager = NewslettersManager.GetManager();
var issues = manager.GetIssues(rootCampaignId);
return issues;
}
}
}


First, you initialize the NewslettersManager. Then, you call GetIssues method to retrieve all issues per campaign. You filter the issues based on the rootCampaignId property.

Another way is to use the other overload of the GetIssues method and filter by the instance of the root campaign. See here for For developers: Query campaigns. The following snippet find all issues per campaign using the campaign instance as a paramer:

Figure 2: Get issues by rootCampaign instance.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Telerik.Sitefinity.Modules.Newsletters;
using Telerik.Sitefinity.Newsletters.Model;
namespace Telerik.Sitefinity.Documentation.CodeSnippets.DevGuide.SitefinityEssentials.Modules.EmailCampaigns
{
public partial class EmailCampaignsSnippets
{
public IQueryable<Campaign> GetIssues(Campaign rootCampaign)
{
NewslettersManager manager = NewslettersManager.GetManager();
var issues = manager.GetIssues(rootCampaign);
return issues;
}
}
}

Via NewslettersManager you can also retrieve the latest issue of a campaign. Use the GetLatestIssue as shown in the example below:

Figure 3: Get latest issue for campaign.

using System;
using Telerik.Sitefinity.Modules.Newsletters;
using Telerik.Sitefinity.Newsletters.Model;
namespace Telerik.Sitefinity.Documentation.CodeSnippets.DevGuide.SitefinityEssentials.Modules.EmailCampaigns
{
public partial class EmailCampaignsSnippets
{
public Campaign GetLatestIssue(Guid rootCampaignId)
{
NewslettersManager manager = NewslettersManager.GetManager();
var latestIssue = manager.GetLatestIssue(rootCampaignId);
return latestIssue;
}
}
}

NOTE: If no campaign with the specified ID exists, the GetIssues method throwsTelerik.Sitefinity.SitefinityExceptions.ItemNotFoundException exception.

Want to learn more?

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?

Next article

Modify issues