Question

I'm writing a web part that needs to use connections for processing values relating to a business object called a "Program Entity". It is supposed to take in an ID provided by a connected web part, perform some processing, then spit out a 'token' for consumption by a different connected web part. The token is just the ID in another format.

I have the drop-down menu correctly displaying as follows:

Connections -> Send Program Entity Token To -> ...
            -> Get Program Entity ID From -> ...

When I select a web part in "Get Program Entity ID From", a dialog appears for me to choose a Filtered Parameter. However the dropdown of parameters is greyed out and just says "No Parameters". Note: the web part I'm trying to connect to is also custom and may not have been fully completed and tested for providing a value via a connection.

Is there anything that explains why I'm unable to set up a connection? Here is the code for my web part:

public class ProgramEntityTokenConverter : WebPart, ITransformableFilterValues
{
    public bool AllowAllValue
    {
    	get { return true; }
    }

    public bool AllowEmptyValue
    {
    	get { return false; }
    }

    public bool AllowMultipleValues
    {
    	get { return false; }
    }

    public string ParameterName
    {
    	get { return "ProgramEntityToken"; }
    }

    public ReadOnlyCollection<string> ParameterValues
    {
    	get { return new ReadOnlyCollection<string>(ConvertProgramEntityIDs()); }
    }

    [ConnectionProvider("Program Entity Token", "ProgramEntityToken", AllowsMultipleConnections = false)]
    public ITransformableFilterValues SetConnectionInterface()
    {
    	return this;
    }

    private IList<string> ConvertProgramEntityIDs()
    {
    	return null; // TODO
    }

    [ConnectionConsumer("Program Entity ID", "ProgramEntityID", AllowsMultipleConnections = false)]
    public void SetFilter(IFilterValues filterValues)
    {
    	if (filterValues != null)
    	{
    		EnsureChildControls();
    		List<ConsumerParameter> parameters = new List<ConsumerParameter>();
    		parameters.Add(new ConsumerParameter("ProgramEntityID", ConsumerParameterCapabilities.SupportsSingleValue));
    		filterValues.SetConsumerParameters(new ReadOnlyCollection<ConsumerParameter>(parameters));
    	}
    }
}
Was it helpful?

Solution

Now fixed by changing this line:

parameters.Add(new ConsumerParameter("ProgramEntityID", 
    ConsumerParameterCapabilities.SupportsSingleValue));

to this line:

parameters.Add(new ConsumerParameter("ProgramEntityID", 
    ConsumerParameterCapabilities.SupportsSingleValue | 
    ConsumerParameterCapabilities.SupportsAllValue));

The web part I was trying to connect to had the AllowAllValue property set to true which was clearly excluded by ConsumerParameterCapabilities.


As an aside, I also tried:

parameters.Add(new ConsumerParameter("ProgramEntityID", 
    ConsumerParameterCapabilities.SupportsMultipleValues | 
    ConsumerParameterCapabilities.SupportsAllValue));

... however the web part I'm connecting to has AllowMultipleValues set to false! It seems odd that ConsumerParameterCapabilities enforces possible connections according to AllowAllValue but AllowMultipleValues does not.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top