Request for a simple macros for generating EZproxy URLs

Animus A. shared this question 11 days ago
Answered

I'd like to put a request for a simple macros compatible with Citavi 5: if reference contains DOI, then add new Web location by appending (for example)

https://ezproxy.university.edu/url?=https://doi.org/

before DOI. Or, alternatively, https://doi.org/... URL can be used for generating EZproxy URL.

I understand that asking for a custom macros is beyond any reasonable support request, yet I believe that this kind of macros can be useful to almost everyone. 'Find full text' function doesn't work sometimes, so having direct EZproxy link is a good workaround. Citavi's GitHub page contains far more complex and niche macroses, but nothing like what I'm asking for.

Best Answer
photo

Hi

this sample code should help you to achieve this goal in Citavi 5:

foreach (Reference reference in references)
{
	if (!String.IsNullOrWhiteSpace(reference.Doi))
	{
		string ezurl = String.Concat("https://ezproxy.university.edu/url?=https://doi.org/";, reference.Doi);
		Location ezproxy = new Location(reference, LocationType.ElectronicAddress, ezurl);
		reference.Locations.Add(ezproxy);
	}				
}
Please note, however, that this will not work in Citavi 6!

Best regards

Sebastian

Comments (1)

photo
1

Hi

this sample code should help you to achieve this goal in Citavi 5:

foreach (Reference reference in references)
{
	if (!String.IsNullOrWhiteSpace(reference.Doi))
	{
		string ezurl = String.Concat("https://ezproxy.university.edu/url?=https://doi.org/";, reference.Doi);
		Location ezproxy = new Location(reference, LocationType.ElectronicAddress, ezurl);
		reference.Locations.Add(ezproxy);
	}				
}
Please note, however, that this will not work in Citavi 6!

Best regards

Sebastian

photo
1

Thanks for noticing my request! I've tested this simple code:

using System;
using System.Linq;
using System.ComponentModel;
using System.Collections.Generic;
using System.Windows.Forms;

using SwissAcademic.Citavi;
using SwissAcademic.Citavi.Metadata;
using SwissAcademic.Citavi.Shell;
using SwissAcademic.Collections;

public static class CitaviMacro
{
	public static void Main()
	{
		List<Reference> references = Program.ActiveProjectShell.PrimaryMainForm.GetFilteredReferences();
		SwissAcademic.Citavi.Project activeProject = Program.ActiveProjectShell.Project;
		
		foreach (Reference reference in references)
		{
			ReferenceType referenceType = reference.ReferenceType;
			if (!String.IsNullOrWhiteSpace(reference.Doi))
			{
				string ezurl = String.Concat("https://ezproxy.university.edu/url?=https://doi.org/";, reference.Doi);
				Location ezproxy = new Location(reference, LocationType.ElectronicAddress, ezurl);
			}
		}	
	}
}

It compiles without any errors yet it's execution does nothing. What am I missing here?

photo
1

Hi, you missed the line that links the newly created Location is linked to the reference:

reference.Locations.Add(ezproxy);
Best regards
Sebastian

photo
1

True! Thank you, Sabastian, you're the best.

photo
Leave a Comment
 
Attach file (NO confidential documents!)