locked
Pluging on opportunity create/update automatic records created/updateed in custom entity in crm 4.0 RRS feed

  • General discussion

  • Hi All,<u1:p></u1:p><o:p></o:p>

    I want to create a plugins for create/update custom entity:<u1:p></u1:p><o:p></o:p>

    If opportunity is create then automatic custom entity record will be created.<u1:p></u1:p><o:p></o:p>

                            In the opportunity entity two fields(Start date or End date), if startdate.year != enddate.year then multiple records created in custom entity.<u1:p></u1:p><o:p></o:p>

                            ex:-if sttartdate.year (2011) and enddate.year(2014) then 4 record is created in custom entity<u1:p></u1:p><o:p></o:p>

    Same as, when opportunity updated, all(4) records of custom entity should be updated. <o:p></o:p>

    It's very urgent, please help me.<o:p></o:p>

    Thanks for Advance,<o:p></o:p>

    Pankaj <o:p></o:p>

    Wednesday, August 22, 2012 11:26 AM

All replies

  • hi

    check this

    using System;
    using System.Collections.Generic;
    using System.Text;
    using Microsoft.Crm.Sdk;
    using Microsoft.Crm.SdkTypeProxy;
    using Microsoft.Crm.Sdk.Query;
    using System.Collections;
    using System.Data;
    using System.Data.SqlClient;
    namespace Microsoft.Crm.Sdk.UpdatingOppndCustomEnt
    
    {
    
    public class CreateCsmRecords : IPlugin
    {
    
    public void Execute(IPluginExecutionContext context)
    {
    
    if (context.PrimaryEntityName == EntityName.opportunity.ToString() && context.InputParameters.contains("Target"))
    
    {
    
    
    DynamicEntity OppEnt = context.InputParameters["Target"] as DynamicEntity;
    
    
    ICrmService service = context.CreateCrmService(false);
    
    /// write u r logic here ...now u have opportunity record in OPPeNT
    }
    }
    }
    }
    
    


    Please don't forget to Vote and marked as answer If this post answers your question or was helpful, please click "Mark As Answer" on the post and "Mark as Helpful" Be wise

    Thursday, August 23, 2012 11:30 PM