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)

Constructor Error

(0) ShareShare
ReportReport
Posted on by

Hi all

I've tried to change a Dialog Workflow with a plugin to a entity that on save runs the plugin to do the same thing. Problem is it produces the following error

Unexpected exception from plug-in (Constructor): Stan.ManholePrice: System.MissingMethodException: Constructor on type 'Stan.ManholePrice' not found.

I'm not sure if the plugin should now be a Iplugin insted of a codeactivity or am i just missing something in the code to enable it to run from an entity. Here is the start of the code and where i think the issue is. I have tried following some guides but they all seem to be based round the fact the plugin is an Iplugin

  public class ManholePrice : CodeActivity

    {

     

        #region Secure/Unsecure Configuration Setup

        private string _secureConfig = null;

        private string _unsecureConfig = null;

        public ManholePrice(string unsecureConfig, string secureConfig)

        {

            _secureConfig = secureConfig;

            _unsecureConfig = unsecureConfig;

        }

        #endregion

        protected override void Execute(CodeActivityContext executionContext)

        {

            //Create the tracing service

            ITracingService tracingService = executionContext.GetExtension<ITracingService>();

            //Create the context

            IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();

            IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();

            IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

            // Create a column set to define which attributes should be retrieved.

            ColumnSet attributes = new ColumnSet(true);

            Entity currentPriceLevelEntity = new Entity("pricelevel");

            currentPriceLevelEntity = service.Retrieve("pricelevel", CurrentPriceList.Get<EntityReference>(executionContext).Id, attributes);

            // Create New Price List

            Entity newPriceLevel = new Entity("pricelevel");

            newPriceLevel["name"] = NewPriceListName.Get<string>(executionContext);

            newPriceLevel["transactioncurrencyid"] = currentPriceLevelEntity["transactioncurrencyid"];

            Guid newPriceLevelId = service.Create(newPriceLevel);

            newPriceLevel["Price900"] = ManholePrice900.Get<string>(executionContext);

            newPriceLevel["Price1050"] = ManholePrice1050.Get<string>(executionContext);

            newPriceLevel["Price1200"] = ManholePrice1200.Get<string>(executionContext);

Any advice would be greatly appreciated

Regards

Dan

*This post is locked for comments

I have the same question (0)
  • Verified answer
    tw0sh3ds Profile Picture
    5,600 on at

    Hi Dan,

    I'm not sure what you are trying to do here but Secure config and unsecure config is only for plugins. Delete all this:

            #region Secure/Unsecure Configuration Setup
            private string _secureConfig = null;
            private string _unsecureConfig = null;
            public ManholePrice(string unsecureConfig, string secureConfig)
            {
                _secureConfig = secureConfig;
                _unsecureConfig = unsecureConfig;
            }
            #endregion


    and the error should no longer exist.

    So if you are creating plugin - you should use IPlugin interface.

    If you are doing Workflow Activity - you should use CodeActivity.

  • ScottDurow Profile Picture
    21 on at

    Hi - yes you need to remove the CodeActivity base class and use the IPlugin interface.

  • Community Member Profile Picture
    on at

    Thank you that worked like a dream

    Many Thanks

    Dan

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