Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

plug in seems that it has no effect

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I've built a plugin with no issues and registered it using plug-in registration tool with no problem but its seems like it has no effect the plug-in force calculation for a roll-up field named rejected on vacancies entity  where rejected is the count of application that if status =inactive

Anyway i used a custom workflow from workflow tool CodePlex named force \recalculate roll up fields which work fine and automatically perform roll ups once status goes into inactive but the issues is when i deleted the record the workflow didn't trigger in real time which force me to make a plugin i will provide a screen shots about my plugin to explain everything 

the plug-in it-self which force calculation whenever a change occur 

154554.Capture.PNG

here is how i registered the plug

5822.Capture2.PNG

in on update if attributes rejected or active changed which by them i mean the fields changed make force the roll to occur 

sorry for the long question 

Best Regards 

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: plug in seems that it has no effect

    thanks for the replay that is some usefull info

    really appriciated best regards w

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: plug in seems that it has no effect

    Hii, lately i created a plugin to update the quantity on child entity when the parent entity is deleted. I dont know if its meet your requirement or not. But i thinks it will help a bit.

    Please take a look at my code:

    public void Execute(IServiceProvider serviceprovider)
            {
                IPluginExecutionContext context = (IPluginExecutionContext)serviceprovider.GetService(typeof(IPluginExecutionContext));
                IOrganizationServiceFactory servicefactory = (IOrganizationServiceFactory)serviceprovider.GetService(typeof(IOrganizationServiceFactory));
                IOrganizationService service = servicefactory.CreateOrganizationService(context.UserId);
    
                if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is EntityReference)
                {
    		//If Delete, you should use "entityReference". Not Entity
    
                    EntityReference entityreference = (EntityReference)context.InputParameters["Target"];
    
                    if (context.MessageName == "Delete")
                    {
    
                        Entity ent = service.Retrieve(entityreference.LogicalName, entityreference.Id, new ColumnSet("new_productname"));
    		    
    		    // Product Name is a Look Up Field That Contain the name of product which i want to update the quantity.
    		    var productname = ent.GetAttributeValue<EntityReference>("new_productname");
    
                        if (productname != null)
                        {
    			// Getting quantity field from child entity
                            Entity product = service.Retrieve(productname.LogicalName, productname.Id, new ColumnSet("new_quantity"));
                            
    			// Update the quantity on child entity
                            var number = product.GetAttributeValue<Decimal>("new_quantity");
                            var sisaunit = number + 1;                        
                            product.Attributes["new_quantity"] = sisaunit;
                            service.Update(product);
    
                        }
    
                      
    
                    }


    Best Regars
    Fikri

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: plug in seems that it has no effect

    hey wei fun thanks for your answer and error occur when i am trying the register this plug in on delete and i cant use the custom work flow provided by codeplex because if i want it run on dlete i would take time ti update the roll up field and i want the roll up field to r=be recalculated automatically after the deletion of the record

    Best Regards  

  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: plug in seems that it has no effect

    First,

     i am assuming your application is child entity and vicancy  is in parent entity.

    if you are using post operation, you should include the preimage , in order to get your parent entity id , and do the rollup.

    0550.plugin.PNG

    Pre Image and Post Image

    www.youtube.com/watch

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: plug in seems that it has no effect

    thanks wie fun i am exactly i am planing to trigger the plug in once an application is deleted to update the roll up filed in vicancy but i am having an issue knowing if i should update the plug in code or even regestring the plugin and no i am not using a workflow .

  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: plug in seems that it has no effect

    you should register your plugin Message as Delete, if you plan to trigger the plugin during Delete.

    if you are using workflow, you should checked the Delete as picture shown below.

    8081.delete.png

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: plug in seems that it has no effect

    you mean i should register it on delete of the application but it run on vacancie entity can you please specify where to make changes like should  i change the primary and secondery entity while regestring the plug in ,or should i change the code ,any help would be appriciated thanks for your time

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: plug in seems that it has no effect

    I think you should write the plugin on delete of the application entity. Get the guid of the vacancy entity from the lookup field and execute the rollup calculation request.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,321 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans