web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

No plugins have been selected from the list. Please select at least one and try again." while publishing the Custom Workflow Activity with Plugin Registration Tool

(0) ShareShare
ReportReport
Posted on by 1,434

namespace Workflow
{

using Microsoft.Crm.Sdk.Messages;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Sdk.Workflow;

using System;
using System.Activities;

public partial class CustomWorkflow: CodeActivity
{
/// <summary>
/// Define property for DayofWeeks
/// </summary>
[Output("DayofWeek")]
public OutArgument<String> DayofWeek { get; set; }

/// <summary>
/// Define override method for custom workflow Execute
/// </summary>
/// <param name="Execution"></param>
protected override void Execute(CodeActivityContext Execution)
{

string Day = string.Empty;
DateTime _Date = DateTime.MinValue;

//Get context
IWorkflowContext context = Execution.GetExtension<IWorkflowContext>();

//Create iorganization service object
IOrganizationServiceFactory serviceFactory = Execution.GetExtension<IOrganizationServiceFactory>();
IOrganizationService service = serviceFactory.CreateOrganizationService(context.InitiatingUserId);

//Get created date of the lead
Entity _lead = (Entity)service.Retrieve("lead", context.PrimaryEntityId, new ColumnSet(new string[] { "createdon" }));
if (_lead.Contains("createdon"))
{
//get day of the week based on created on date
Day = ((DateTime)_lead.Attributes["createdon"]).DayOfWeek.ToString();
}

//Set value to output variable
DayofWeek.Set(Execution, Day);

if (Day == "Sunday")
{
Guid _UserID = GetUserID(service);
AssignLead(service, context.PrimaryEntityId, _UserID);
}
}

/// <summary>
/// To get Userid
/// </summary>
/// <param name="service"></param>
/// <returns></returns>
private Guid GetUserID(IOrganizationService service)
{
Guid _UserID = Guid.Empty;

ConditionExpression condition1 = new ConditionExpression();
condition1.AttributeName = "firstname";
condition1.Operator = ConditionOperator.Equal;
condition1.Values.Add("Vishanshu");

ConditionExpression condition2 = new ConditionExpression();
condition2.AttributeName = "lastname";
condition2.Operator = ConditionOperator.Equal;
condition2.Values.Add("Jain");

FilterExpression filter1 = new FilterExpression();
filter1.Conditions.AddRange(condition1, condition2);
QueryExpression query = new QueryExpression("systemuser");
query.Criteria.AddFilter(filter1);

EntityCollection EntityCol = service.RetrieveMultiple(query);
if (EntityCol.Entities.Count > 0)
{
Entity _User = (Entity)EntityCol.Entities[0];
_UserID = _User.Id;
}
return _UserID;
}

/// <summary>
/// AssignLead to user
/// </summary>
/// <param name="service"></param>
/// <param name="LeadID"></param>
/// <param name="UserID"></param>
private void AssignLead(IOrganizationService service, Guid LeadID, Guid UserID)
{
AssignRequest _Assign = new AssignRequest()
{
Assignee = new EntityReference("systemuser", UserID),
Target = new EntityReference("lead", LeadID)
};
service.Execute(_Assign);
}
}
}

*This post is locked for comments

I have the same question (0)
  • Aileen Gusni Profile Picture
    44,524 on at

    Hi Abhishek,

    Based on your tag it is for CRM 2013, not CRM 4.0 right?

    I was trying using your code and it is fine in my environment.

    You have make it as public class as well.

    public partial class CustomWorkflow: CodeActivity

    Some are using public partial class, some are only using public class, but I tried both are working.

    Yes, Guido is right, you need to check the signed assembly.

    And refer to this:

    social.microsoft.com/.../getting-the-message-no-plugins-have-been-selected-from-the-list-please-select-at-least-one-and-try

    Thanks.

  • Hosk Profile Picture
    on at

    can you tell us what exactly you are doing in the plugin registation tool.

    list down the steps you are going through and this will help us understand the problem

  • Suggested answer
    Nuno Profile Picture
    2,005 on at

    Hi Abhishe,

    That error happens when trying to register a plugin or workflow activity and none is selected to be registered as this screenshot shows. Selecte at least on.

  • Suggested answer
    Hosk Profile Picture
    on at

    it looks like in the screen shot you are not selected (e.g. checking the box) any of the plugins.

    I think you need to check one

  • Abhishek.Srivastava Profile Picture
    1,434 on at

    But When we Load Assembly then No List is coming. so unable to select.Currently we are using CRM 2013 SDK Plunging Registration tool. Please see the Image as given below.

  • Nuno Profile Picture
    2,005 on at

    Hi Abhishek,

    From the image about the error you are getting, looks like that you dont have any class that extends CodeActivity in your CustomWorkflow project or none that is public.

  • Abhishek.Srivastava Profile Picture
    1,434 on at

    Thank you very much Guido. It work now ..!!!

  • Suggested answer
    mehul512 Profile Picture
    25 on at

    Thanks Guido. It works for me :)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans