Asked by:
Upgrading Plugin from CRM 4 to CRM 2013

Question
-
Hi, I need to upgrade my crm plugin from 4.0 to 2013, how can I change the following plugin from 4.0 to 2013 ??
thank you!
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Crm.Sdk; using Microsoft.Crm.Sdk.Query; using Microsoft.Crm.SdkTypeProxy; // Post Stage Win namespace Assembly.OpportunityStep { internal static class JoinBuyerPostWin { private const string PRIMARY_ENTITY_NAME = RegisteredEntityName.Opportunity; private const string SECONDARY_ENTITY_NAME = ""; private const string MESSAGE_NAME = MessageName.Win; private const int MESSAGE_PROCESSING_STAGE = MessageProcessingStage.Post; private const int MESSAGE_PROCESSING_MODE = MessageProcessingMode.Synchronous; private const int INVOCATION_SOURCE = MessageInvocationSource.Parent; internal static void Go(IPluginExecutionContext context) { if (ToolkitHelper.VerifyPluginStepInfo(context, PRIMARY_ENTITY_NAME, SECONDARY_ENTITY_NAME, MESSAGE_NAME, MESSAGE_PROCESSING_STAGE, MESSAGE_PROCESSING_MODE, INVOCATION_SOURCE)) { DynamicEntity closedOpportunity = (DynamicEntity)context.InputParameters["OpportunityClose"]; ICrmService service = context.CreateCrmService(false); DynamicEntity originOpportunity = ToolkitHelper.RetrieveEntity(service, RegisteredEntityName.Opportunity, ((Lookup)closedOpportunity.Properties["opportunityid"]).Value); if (originOpportunity.Properties.Contains("ppc_lotid")) { Guid lotId = ((Lookup)originOpportunity.Properties["ppc_lotid"]).Value; // Check for joint buyer - LCY Guid[] jointBuyerIds = GetJointBuyerId(service, ((Key)originOpportunity.Properties["opportunityid"]).Value); if (jointBuyerIds.Length > 0) { foreach (Guid contactId in jointBuyerIds) { ToolkitHelper.AssociateEntity(service, RegisteredEntityName.Contact, contactId, RegisteredEntityName.Lot, lotId, "ppc_ppc_lot_contact"); } } if (originOpportunity.Properties.Contains("originOpportunity")) { if (((Customer)originOpportunity.Properties["customerid"]).type == RegisteredEntityName.Contact) { ToolkitHelper.AssociateEntity(service, RegisteredEntityName.Contact, ((Customer)originOpportunity.Properties["customerid"]).Value, RegisteredEntityName.Lot, lotId, "ppc_ppc_lot_contact"); } } #region UpdateLot if (originOpportunity.Properties.Contains("ppc_lotid")) { //TEMP hid /* Decimal nettPrice = ((CrmMoney)originOpportunity.Properties["estimatedvalue"]).IsNull ? 0 : ((CrmMoney)originOpportunity.Properties["estimatedvalue"]).Value; Decimal outRight = ((CrmMoney)originOpportunity.Properties["ppc_outrightdiscount"]).IsNull ? 0 : ((CrmMoney)originOpportunity.Properties["ppc_outrightdiscount"]).Value; Decimal Special = ((CrmMoney)originOpportunity.Properties["ppc_specialdiscount"]).IsNull ? 0 : ((CrmMoney)originOpportunity.Properties["ppc_specialdiscount"]).Value; Decimal Credit = ((CrmMoney)originOpportunity.Properties["ppc_creditnote"]).IsNull ? 0 : ((CrmMoney)originOpportunity.Properties["ppc_creditnote"]).Value; Decimal SPA = ((CrmMoney)originOpportunity.Properties["ppc_spaprice"]).IsNull ? 0 : ((CrmMoney)originOpportunity.Properties["ppc_spaprice"]).Value; Decimal totalDiscount = ((CrmMoney)originOpportunity.Properties["ppc_totaldiscount"]).IsNull ? 0 : ((CrmMoney)originOpportunity.Properties["ppc_totaldiscount"]).Value; Decimal totalDiscountPercent = ((CrmDecimal)originOpportunity.Properties["ppc_totaldiscountpercentage"]).IsNull ? 0 : ((CrmDecimal)originOpportunity.Properties["ppc_totaldiscountpercentage"]).Value; Decimal outRightPercent = ((CrmDecimal)originOpportunity.Properties["ppc_outrightdiscountpercentage"]).IsNull ? 0 : ((CrmDecimal)originOpportunity.Properties["ppc_outrightdiscountpercentage"]).Value; Decimal SpecialPercent = ((CrmDecimal)originOpportunity.Properties["ppc_specialdiscountpercentage"]).IsNull ? 0 : ((CrmDecimal)originOpportunity.Properties["ppc_specialdiscountpercentage"]).Value; Decimal CreditPercent = ((CrmDecimal)originOpportunity.Properties["ppc_creditnotepercentage"]).IsNull ? 0 : ((CrmDecimal)originOpportunity.Properties["ppc_creditnotepercentage"]).Value; Decimal movinginBonus = ((CrmMoney)originOpportunity.Properties["ppc_movinginbonus"]).IsNull ? 0 : ((CrmMoney)originOpportunity.Properties["ppc_movinginbonus"]).Value; Decimal movinginBonusPercent = ((CrmDecimal)originOpportunity.Properties["ppc_movinginbonuspercentage"]).IsNull ? 0 : ((CrmDecimal)originOpportunity.Properties["ppc_movinginbonuspercentage"]).Value; Decimal rebate = ((CrmMoney)originOpportunity.Properties["ppc_rebateuponvp"]).IsNull ? 0 : ((CrmMoney)originOpportunity.Properties["ppc_rebateuponvp"]).Value; Decimal rebatePercent = ((CrmDecimal)originOpportunity.Properties["ppc_rebatepercentage"]).IsNull ? 0 : ((CrmDecimal)originOpportunity.Properties["ppc_rebatepercentage"]).Value; Decimal deferred = ((CrmMoney)originOpportunity.Properties["ppc_deferredpayment"]).IsNull ? 0 : ((CrmMoney)originOpportunity.Properties["ppc_deferredpayment"]).Value; Decimal deferredPercent = ((CrmDecimal)originOpportunity.Properties["ppc_deferredpercentage"]).IsNull ? 0 : ((CrmDecimal)originOpportunity.Properties["ppc_deferredpercentage"]).Value; Decimal amountPayable = ((CrmMoney)originOpportunity.Properties["ppc_amountpayablebypurchaser"]).IsNull ? 0 : ((CrmMoney)originOpportunity.Properties["ppc_amountpayablebypurchaser"]).Value; Decimal referralFees = ((CrmMoney)originOpportunity.Properties["ppc_referralfees"]).IsNull ? 0 : ((CrmMoney)originOpportunity.Properties["ppc_referralfees"]).Value; Decimal loanAmount = ((CrmMoney)originOpportunity.Properties["ppc_loanamount"]).IsNull ? 0 : ((CrmMoney)originOpportunity.Properties["ppc_loanamount"]).Value; Decimal loanAmountPercent = ((CrmDecimal)originOpportunity.Properties["ppc_loanamountpercentage"]).IsNull ? 0 : ((CrmDecimal)originOpportunity.Properties["ppc_loanamountpercentage"]).Value; Decimal agentComm = ((CrmMoney)originOpportunity.Properties["ppc_agentcommission"]).IsNull ? 0 : ((CrmMoney)originOpportunity.Properties["ppc_agentcommission"]).Value; Decimal agentCommPercent = ((CrmDecimal)originOpportunity.Properties["ppc_agentcommissionpercentage"]).IsNull ? 0 : ((CrmDecimal)originOpportunity.Properties["ppc_agentcommissionpercentage"]).Value; Decimal staffComm = ((CrmMoney)originOpportunity.Properties["ppc_staffcommission"]).IsNull ? 0 : ((CrmMoney)originOpportunity.Properties["ppc_staffcommission"]).Value; Decimal staffCommPercent = ((CrmDecimal)originOpportunity.Properties["ppc_staffcommissionpercentage"]).IsNull ? 0 : ((CrmDecimal)originOpportunity.Properties["ppc_staffcommissionpercentage"]).Value; Decimal spaLegalFees = ((CrmMoney)originOpportunity.Properties["ppc_spalegalfees"]).IsNull ? 0 : ((CrmMoney)originOpportunity.Properties["ppc_spalegalfees"]).Value; Decimal loanAgreement = ((CrmMoney)originOpportunity.Properties["ppc_loanagreementlegalfees"]).IsNull ? 0 : ((CrmMoney)originOpportunity.Properties["ppc_loanagreementlegalfees"]).Value; Decimal disbursementSPA = ((CrmMoney)originOpportunity.Properties["ppc_disbursementspa"]).IsNull ? 0 : ((CrmMoney)originOpportunity.Properties["ppc_disbursementspa"]).Value; Decimal disbursementLoan = ((CrmMoney)originOpportunity.Properties["ppc_disbursementloan"]).IsNull ? 0 : ((CrmMoney)originOpportunity.Properties["ppc_disbursementloan"]).Value; */ Decimal nettPrice = ((CrmMoney)originOpportunity.Properties["estimatedvalue"]).Value; Decimal outRight = ((CrmMoney)originOpportunity.Properties["ppc_outrightdiscount"]).Value; Decimal Special = ((CrmMoney)originOpportunity.Properties["ppc_specialdiscount"]).Value; Decimal Credit = ((CrmMoney)originOpportunity.Properties["ppc_creditnote"]).Value; Decimal SPA = ((CrmMoney)originOpportunity.Properties["ppc_spaprice"]).Value; Decimal totalDiscount = ((CrmMoney)originOpportunity.Properties["ppc_totaldiscount"]).Value; Decimal totalDiscountPercent = ((CrmDecimal)originOpportunity.Properties["ppc_totaldiscountpercentage"]).Value; Decimal outRightPercent = ((CrmDecimal)originOpportunity.Properties["ppc_outrightdiscountpercentage"]).Value; Decimal SpecialPercent = ((CrmDecimal)originOpportunity.Properties["ppc_specialdiscountpercentage"]).Value; Decimal CreditPercent = ((CrmDecimal)originOpportunity.Properties["ppc_creditnotepercentage"]).Value; Decimal movinginBonus = ((CrmMoney)originOpportunity.Properties["ppc_movinginbonus"]).Value; Decimal movinginBonusPercent = ((CrmDecimal)originOpportunity.Properties["ppc_movinginbonuspercentage"]).Value; Decimal rebate = ((CrmMoney)originOpportunity.Properties["ppc_rebateuponvp"]).Value; Decimal rebatePercent = ((CrmDecimal)originOpportunity.Properties["ppc_rebatepercentage"]).Value; Decimal deferred = ((CrmMoney)originOpportunity.Properties["ppc_deferredpayment"]).Value; Decimal deferredPercent = ((CrmDecimal)originOpportunity.Properties["ppc_deferredpercentage"]).Value; Decimal amountPayable = ((CrmMoney)originOpportunity.Properties["ppc_amountpayablebypurchaser"]).Value; Decimal referralFees = ((CrmMoney)originOpportunity.Properties["ppc_referralfees"]).Value; Decimal loanAmount = ((CrmMoney)originOpportunity.Properties["ppc_loanamount"]).Value; Decimal loanAmountPercent = ((CrmDecimal)originOpportunity.Properties["ppc_loanamountpercentage"]).Value; Decimal agentComm = ((CrmMoney)originOpportunity.Properties["ppc_agentcommission"]).Value; Decimal agentCommPercent = ((CrmDecimal)originOpportunity.Properties["ppc_agentcommissionpercentage"]).Value; Decimal staffComm = ((CrmMoney)originOpportunity.Properties["ppc_staffcommission"]).Value; Decimal staffCommPercent = ((CrmDecimal)originOpportunity.Properties["ppc_staffcommissionpercentage"]).Value; Decimal spaLegalFees = ((CrmMoney)originOpportunity.Properties["ppc_spalegalfees"]).Value; Decimal loanAgreement = ((CrmMoney)originOpportunity.Properties["ppc_loanagreementlegalfees"]).Value; Decimal disbursementSPA = ((CrmMoney)originOpportunity.Properties["ppc_disbursementspa"]).Value; Decimal disbursementLoan = ((CrmMoney)originOpportunity.Properties["ppc_disbursementloan"]).Value; //CrmBoolean calcBasedOn = ((CrmBoolean)originOpportunity.Properties["ppc_calculationbasedon"]); //mod_Chen_20120406_start /* CrmBoolean contra = ((CrmBoolean)originOpportunity.Properties["ppc_contra"]); CrmBoolean dibs = ((CrmBoolean)originOpportunity.Properties["ppc_dibs"]); CrmBoolean cashbuyer = ((CrmBoolean)originOpportunity.Properties["ppc_cashbuyer"]); //CrmBoolean staff = ((CrmBoolean)originOpportunity.Properties["ppc_staff"]); CrmBoolean staff = new CrmBoolean(); if (originOpportunity.Properties.Contains("ppc_staff")) staff = ((CrmBoolean)originOpportunity.Properties["ppc_staff"]); CrmBoolean zippletter = ((CrmBoolean)originOpportunity.Properties["ppc_zippletter"]); CrmBoolean twoyearsfreeinterest = ((CrmBoolean)originOpportunity.Properties["ppc_2yearsfreeinterest"]); */ CrmBoolean contra = new CrmBoolean(); if (originOpportunity.Properties.Contains("ppc_contra")) contra = ((CrmBoolean)originOpportunity.Properties["ppc_contra"]); CrmBoolean dibs = new CrmBoolean(); if (originOpportunity.Properties.Contains("ppc_dibs")) dibs = ((CrmBoolean)originOpportunity.Properties["ppc_dibs"]); CrmBoolean cashbuyer = new CrmBoolean(); if (originOpportunity.Properties.Contains("ppc_cashbuyer")) cashbuyer = ((CrmBoolean)originOpportunity.Properties["ppc_cashbuyer"]); CrmBoolean staff = new CrmBoolean(); if (originOpportunity.Properties.Contains("ppc_staff")) staff = ((CrmBoolean)originOpportunity.Properties["ppc_staff"]); CrmBoolean zippletter = new CrmBoolean(); if (originOpportunity.Properties.Contains("ppc_zippletter")) zippletter = ((CrmBoolean)originOpportunity.Properties["ppc_zippletter"]); CrmBoolean twoyearsfreeinterest = new CrmBoolean(); if (originOpportunity.Properties.Contains("ppc_2yearsfreeinterest")) twoyearsfreeinterest = ((CrmBoolean)originOpportunity.Properties["ppc_2yearsfreeinterest"]); //mod_Chen_20120406_end string desc = string.Empty; if (originOpportunity.Properties.Contains("description")) desc = ((string)originOpportunity.Properties["description"]).ToString(); Guid agent = new Guid(); if (originOpportunity.Properties.Contains("ppc_agentid")) agent = ((Lookup)originOpportunity.Properties["ppc_agentid"]).Value; Guid referredBy = new Guid(); if (originOpportunity.Properties.Contains("ppc_referredbyid")) referredBy = ((Lookup)originOpportunity.Properties["ppc_referredbyid"]).Value; Guid spaLawyerInCharge = new Guid(); if (originOpportunity.Properties.Contains("ppc_spalawyerinchargeid")) spaLawyerInCharge = ((Lookup)originOpportunity.Properties["ppc_spalawyerinchargeid"]).Value; Guid loanLawyerInCharge = new Guid(); if (originOpportunity.Properties.Contains("ppc_loanlawyerinchargeid")) loanLawyerInCharge = ((Lookup)originOpportunity.Properties["ppc_loanlawyerinchargeid"]).Value; Guid loanFinancier = new Guid(); if (originOpportunity.Properties.Contains("ppc_loanfinancierid")) loanFinancier = ((Lookup)originOpportunity.Properties["ppc_loanfinancierid"]).Value; string spaInvoiceNo = string.Empty; if (originOpportunity.Properties.Contains("ppc_spainvoiceno")) spaInvoiceNo = ((string)originOpportunity.Properties["ppc_spainvoiceno"]).ToString(); string loanInvoiceNo = string.Empty; if (originOpportunity.Properties.Contains("ppc_loaninvoiceno")) loanInvoiceNo = ((string)originOpportunity.Properties["ppc_loaninvoiceno"]).ToString(); string spaChequeNo = string.Empty; if (originOpportunity.Properties.Contains("ppc_spachequeno")) spaChequeNo = ((string)originOpportunity.Properties["ppc_spachequeno"]).ToString(); CrmDateTime spaChequeDate = CrmDateTime.Null; if (originOpportunity.Properties.Contains("ppc_spachequedate")) spaChequeDate = ((CrmDateTime)originOpportunity.Properties["ppc_spachequedate"]); string loanChequeNo = string.Empty; if (originOpportunity.Properties.Contains("ppc_loanchequeno")) loanChequeNo = ((string)originOpportunity.Properties["ppc_loanchequeno"]).ToString(); CrmDateTime loanChequeDate = CrmDateTime.Null; if (originOpportunity.Properties.Contains("ppc_loanchequedate")) loanChequeDate = ((CrmDateTime)originOpportunity.Properties["ppc_loanchequedate"]); Int32 specialBenefitsUponVP = 0; if (originOpportunity.Properties.Contains("ppc_specialbenefitsuponvp")) specialBenefitsUponVP = ((Picklist)originOpportunity.Properties["ppc_specialbenefitsuponvp"]).Value; Int32 furniturePackage = 0; if (originOpportunity.Properties.Contains("ppc_furniturepackage")) furniturePackage = ((Picklist)originOpportunity.Properties["ppc_furniturepackage"]).Value; Int32 spaLegalFeesAbsorbBy = 0; if (originOpportunity.Properties.Contains("ppc_spalegalfeesabsorbby")) spaLegalFeesAbsorbBy = ((Picklist)originOpportunity.Properties["ppc_spalegalfeesabsorbby"]).Value; Int32 loanAgreementLegalFeesAbsorbBy = 0; if (originOpportunity.Properties.Contains("ppc_loanagreementlegalfeesabsorbby")) loanAgreementLegalFeesAbsorbBy = ((Picklist)originOpportunity.Properties["ppc_loanagreementlegalfeesabsorbby"]).Value; string dbsSPAInvoiceNo = string.Empty; if (originOpportunity.Properties.Contains("ppc_disbursementspainvoiceno")) dbsSPAInvoiceNo = ((string)originOpportunity.Properties["ppc_disbursementspainvoiceno"]).ToString(); string dbsSPAChequeNo = string.Empty; if (originOpportunity.Properties.Contains("ppc_disbursementspachequeno")) dbsSPAChequeNo = ((string)originOpportunity.Properties["ppc_disbursementspachequeno"]).ToString(); CrmDateTime dbsSPAChequeDate = CrmDateTime.Null; if (originOpportunity.Properties.Contains("ppc_disbursementspachequeon")) dbsSPAChequeDate = ((CrmDateTime)originOpportunity.Properties["ppc_disbursementspachequeon"]); string dbsLoanInvoiceNo = string.Empty; if (originOpportunity.Properties.Contains("ppc_disbursementloaninvoiceno")) dbsLoanInvoiceNo = ((string)originOpportunity.Properties["ppc_disbursementloaninvoiceno"]).ToString(); string dbsLoanChequeNo = string.Empty; if (originOpportunity.Properties.Contains("ppc_disbursementloanchequeno")) dbsLoanChequeNo = ((string)originOpportunity.Properties["ppc_disbursementloanchequeno"]).ToString(); CrmDateTime dbsLoanChequeDate = CrmDateTime.Null; if (originOpportunity.Properties.Contains("ppc_disbursementloanchequeon")) dbsLoanChequeDate = ((CrmDateTime)originOpportunity.Properties["ppc_disbursementloanchequeon"]); string scfInvoiceNo = string.Empty; if (originOpportunity.Properties.Contains("ppc_scfinvoiceno")) scfInvoiceNo = ((string)originOpportunity.Properties["ppc_scfinvoiceno"]).ToString(); string scfChequeNo = string.Empty; if (originOpportunity.Properties.Contains("ppc_scfchequeno")) scfChequeNo = ((string)originOpportunity.Properties["ppc_scfchequeno"]).ToString(); CrmDateTime scfChequeDate = CrmDateTime.Null; if (originOpportunity.Properties.Contains("ppc_scfchequeon")) scfChequeDate = ((CrmDateTime)originOpportunity.Properties["ppc_scfchequeon"]); DynamicEntity update = new DynamicEntity("ppc_lot"); update.Properties.Add(new KeyProperty("ppc_lotid", new Key(lotId))); update.Properties.Add(new CrmMoneyProperty("ppc_nettprice", new CrmMoney(nettPrice))); update.Properties.Add(new CrmDateTimeProperty("ppc_purchasedate", CrmDateTime.Now)); update.Properties.Add(new CrmMoneyProperty("ppc_outrightdiscount", new CrmMoney(outRight))); update.Properties.Add(new CrmMoneyProperty("ppc_specialdiscount", new CrmMoney(Special))); update.Properties.Add(new CrmMoneyProperty("ppc_creditnote", new CrmMoney(Credit))); update.Properties.Add(new CrmMoneyProperty("ppc_spaprice", new CrmMoney(SPA))); update.Properties.Add(new CrmMoneyProperty("ppc_totaldiscount", new CrmMoney(totalDiscount))); update.Properties.Add(new CrmDecimalProperty("ppc_totaldiscountpercentage", new CrmDecimal(totalDiscountPercent))); update.Properties.Add(new CrmDecimalProperty("ppc_outrightdiscountpercentage", new CrmDecimal(outRightPercent))); update.Properties.Add(new CrmDecimalProperty("ppc_specialdiscountpercentage", new CrmDecimal(SpecialPercent))); update.Properties.Add(new CrmDecimalProperty("ppc_creditnotepercentage", new CrmDecimal(CreditPercent))); update.Properties.Add(new CrmMoneyProperty("ppc_movinginbonus", new CrmMoney(movinginBonus))); update.Properties.Add(new CrmDecimalProperty("ppc_movinginbonuspercentage", new CrmDecimal(movinginBonusPercent))); update.Properties.Add(new CrmMoneyProperty("ppc_rebateuponvp", new CrmMoney(rebate))); update.Properties.Add(new CrmDecimalProperty("ppc_rebatepercentage", new CrmDecimal(rebatePercent))); update.Properties.Add(new CrmMoneyProperty("ppc_deferredpayment", new CrmMoney(deferred))); update.Properties.Add(new CrmDecimalProperty("ppc_deferredpercentage", new CrmDecimal(deferredPercent))); update.Properties.Add(new CrmMoneyProperty("ppc_amountpayablebypurchaser", new CrmMoney(amountPayable))); update.Properties.Add(new CrmMoneyProperty("ppc_referralfees", new CrmMoney(referralFees))); update.Properties.Add(new CrmMoneyProperty("ppc_loanamount", new CrmMoney(loanAmount))); update.Properties.Add(new CrmDecimalProperty("ppc_loanamountpercentage", new CrmDecimal(loanAmountPercent))); update.Properties.Add(new CrmMoneyProperty("ppc_agentcommission", new CrmMoney(agentComm))); update.Properties.Add(new CrmDecimalProperty("ppc_agentcommissionpercentage", new CrmDecimal(agentCommPercent))); update.Properties.Add(new CrmMoneyProperty("ppc_staffcommission", new CrmMoney(staffComm))); update.Properties.Add(new CrmDecimalProperty("ppc_staffcommissionpercentage", new CrmDecimal(staffCommPercent))); update.Properties.Add(new CrmMoneyProperty("ppc_spalegalfees", new CrmMoney(spaLegalFees))); update.Properties.Add(new CrmMoneyProperty("ppc_loanagreementlegalfees", new CrmMoney(loanAgreement))); update.Properties.Add(new CrmMoneyProperty("ppc_disbursementspa", new CrmMoney(disbursementSPA))); update.Properties.Add(new CrmMoneyProperty("ppc_disbursementloan", new CrmMoney(disbursementLoan))); //update.Properties.Add(new CrmBooleanProperty("ppc_calculationbasedon", calcBasedOn)); //mod_Chen_20120406_start /* update.Properties.Add(new CrmBooleanProperty("ppc_contra", contra)); update.Properties.Add(new CrmBooleanProperty("ppc_dibs", dibs)); update.Properties.Add(new CrmBooleanProperty("ppc_cashbuyer", cashbuyer)); //update.Properties.Add(new CrmBooleanProperty("ppc_staff", staff)); CrmBoolean _staff = new CrmBoolean(); if (staff != CrmBoolean.Null) { _staff = new CrmBoolean(staff.Value); update.Properties.Add(new CrmBooleanProperty("ppc_staff", _staff)); } else update.Properties.Add(new CrmBooleanProperty("ppc_staff", CrmBoolean.Null)); update.Properties.Add(new CrmBooleanProperty("ppc_zippletter", zippletter)); update.Properties.Add(new CrmBooleanProperty("ppc_2yearsfreeinterest", twoyearsfreeinterest)); */ CrmBoolean _contra = new CrmBoolean(); if (contra != CrmBoolean.Null) { _contra = new CrmBoolean(contra.Value); update.Properties.Add(new CrmBooleanProperty("ppc_contra", _contra)); } else update.Properties.Add(new CrmBooleanProperty("ppc_contra", CrmBoolean.Null)); CrmBoolean _dibs = new CrmBoolean(); if (dibs != CrmBoolean.Null) { _dibs = new CrmBoolean(dibs.Value); update.Properties.Add(new CrmBooleanProperty("ppc_dibs", _dibs)); } else update.Properties.Add(new CrmBooleanProperty("ppc_dibs", CrmBoolean.Null)); CrmBoolean _cashbuyer = new CrmBoolean(); if (cashbuyer != CrmBoolean.Null) { _cashbuyer = new CrmBoolean(cashbuyer.Value); update.Properties.Add(new CrmBooleanProperty("ppc_cashbuyer", _cashbuyer)); } else update.Properties.Add(new CrmBooleanProperty("ppc_cashbuyer", CrmBoolean.Null)); CrmBoolean _staff = new CrmBoolean(); if (staff != CrmBoolean.Null) { _staff = new CrmBoolean(staff.Value); update.Properties.Add(new CrmBooleanProperty("ppc_staff", _staff)); } else update.Properties.Add(new CrmBooleanProperty("ppc_staff", CrmBoolean.Null)); CrmBoolean _zippletter = new CrmBoolean(); if (zippletter != CrmBoolean.Null) { _zippletter = new CrmBoolean(zippletter.Value); update.Properties.Add(new CrmBooleanProperty("ppc_zippletter", _zippletter)); } else update.Properties.Add(new CrmBooleanProperty("ppc_zippletter", CrmBoolean.Null)); CrmBoolean _twoyearsfreeinterest = new CrmBoolean(); if (twoyearsfreeinterest != CrmBoolean.Null) { _twoyearsfreeinterest = new CrmBoolean(twoyearsfreeinterest.Value); update.Properties.Add(new CrmBooleanProperty("ppc_2yearsfreeinterest", _twoyearsfreeinterest)); } else update.Properties.Add(new CrmBooleanProperty("ppc_2yearsfreeinterest", CrmBoolean.Null)); //mod_Chen_20120406_end update.Properties.Add(new StringProperty("ppc_lotdetails", desc)); Lookup _agent = new Lookup(); if (agent != Guid.Empty) { _agent.Value = new Guid(agent.ToString()); update.Properties.Add(new LookupProperty("ppc_agentid", _agent)); } else update.Properties.Add(new LookupProperty("ppc_agentid", Lookup.Null)); Lookup _referredBy = new Lookup(); if (referredBy != Guid.Empty) { _referredBy.Value = new Guid(referredBy.ToString()); update.Properties.Add(new LookupProperty("ppc_referredbyid", _referredBy)); } else update.Properties.Add(new LookupProperty("ppc_referredbyid", Lookup.Null)); Lookup _spaLawyerInCharge = new Lookup(); if (spaLawyerInCharge != Guid.Empty) { _spaLawyerInCharge.Value = new Guid(spaLawyerInCharge.ToString()); update.Properties.Add(new LookupProperty("ppc_spalawyerinchargeid", _spaLawyerInCharge)); } else update.Properties.Add(new LookupProperty("ppc_spalawyerinchargeid", Lookup.Null)); Lookup _loanLawyerInCharge = new Lookup(); if (loanLawyerInCharge != Guid.Empty) { _loanLawyerInCharge.Value = new Guid(loanLawyerInCharge.ToString()); update.Properties.Add(new LookupProperty("ppc_loanlawyerinchargeid", _loanLawyerInCharge)); } else update.Properties.Add(new LookupProperty("ppc_loanlawyerinchargeid", Lookup.Null)); Lookup _loanFinancier = new Lookup(); if (loanFinancier != Guid.Empty) { _loanFinancier.Value = new Guid(loanFinancier.ToString()); update.Properties.Add(new LookupProperty("ppc_loanfinancierid", _loanFinancier)); } else update.Properties.Add(new LookupProperty("ppc_loanfinancierid", Lookup.Null)); update.Properties.Add(new StringProperty("ppc_spainvoiceno", spaInvoiceNo)); update.Properties.Add(new StringProperty("ppc_loaninvoiceno", loanInvoiceNo)); update.Properties.Add(new StringProperty("ppc_spachequeno", spaChequeNo)); update.Properties.Add(new CrmDateTimeProperty("ppc_spachequedate", spaChequeDate)); update.Properties.Add(new StringProperty("ppc_loanchequeno", loanChequeNo)); update.Properties.Add(new CrmDateTimeProperty("ppc_loanchequedate", loanChequeDate)); update.Properties.Add(new StringProperty("ppc_disbursementspainvoiceno", dbsSPAInvoiceNo)); update.Properties.Add(new StringProperty("ppc_disbursementspachequeno", dbsSPAChequeNo)); update.Properties.Add(new CrmDateTimeProperty("ppc_disbursementspachequeon", dbsSPAChequeDate)); update.Properties.Add(new StringProperty("ppc_disbursementloaninvoiceno", dbsLoanInvoiceNo)); update.Properties.Add(new StringProperty("ppc_disbursementloanchequeno", dbsLoanChequeNo)); update.Properties.Add(new CrmDateTimeProperty("ppc_disbursementloanchequeon", dbsLoanChequeDate)); update.Properties.Add(new StringProperty("ppc_scfinvoiceno", scfInvoiceNo)); update.Properties.Add(new StringProperty("ppc_scfchequeno", scfChequeNo)); update.Properties.Add(new CrmDateTimeProperty("ppc_scfchequeon", scfChequeDate)); if (specialBenefitsUponVP != 0) update.Properties.Add(new PicklistProperty("ppc_specialbenefitsuponvp", new Picklist(specialBenefitsUponVP))); else update.Properties.Add(new PicklistProperty("ppc_specialbenefitsuponvp", Picklist.Null)); if (furniturePackage != 0) update.Properties.Add(new PicklistProperty("ppc_furniturepackage", new Picklist(furniturePackage))); else update.Properties.Add(new PicklistProperty("ppc_furniturepackage", Picklist.Null)); if (spaLegalFeesAbsorbBy != 0) update.Properties.Add(new PicklistProperty("ppc_spalegalfeesabsorbby", new Picklist(spaLegalFeesAbsorbBy))); else update.Properties.Add(new PicklistProperty("ppc_spalegalfeesabsorbby", Picklist.Null)); if (loanAgreementLegalFeesAbsorbBy != 0) update.Properties.Add(new PicklistProperty("ppc_loanagreementlegalfeesabsortby", new Picklist(loanAgreementLegalFeesAbsorbBy))); else update.Properties.Add(new PicklistProperty("ppc_loanagreementlegalfeesabsortby", Picklist.Null)); //hhh //update.Properties.Add(new PicklistProperty("ppc_lotstatus", new Picklist(1))); ToolkitHelper.UpdateEntity(service, update); //update owner Owner ownerLookup = (Owner)originOpportunity.Properties["ownerid"]; Guid ownerId = ownerLookup.Value; Guid currentId = ((Key)update.Properties["ppc_lotid"]).Value; ToolkitHelper.AssignEntity(service, currentId, RegisteredEntityName.Lot, ownerId); } #endregion UpdateLot } } } private static Guid GetJointBuyerRelationshipRoleId(ICrmService service) { #region Setup Conditions FilterExpression filter = new FilterExpression(); // Condition 1 - Name = "Joint Buyer" - LCY ConditionExpression condition1 = new ConditionExpression(); condition1.AttributeName = "name"; condition1.Operator = ConditionOperator.Equal; condition1.Values = new object[] { "Joint Buyer" }; filter.Conditions.Add(condition1); // Condition 2 - statecode is active - LCY ConditionExpression condition2 = new ConditionExpression(); condition2.AttributeName = "statecode"; condition2.Operator = ConditionOperator.Equal; condition2.Values = new object[] { (int)RelationshipRoleState.Active }; filter.Conditions.Add(condition2); // Combine all conditions into filter - LCY filter.FilterOperator = LogicalOperator.And; #endregion BusinessEntityCollection collection = ToolkitHelper.RetrieveMultiple(service, new string[] { "relationshiproleid" }, RegisteredEntityName.RelationshipRole, filter); if (collection.BusinessEntities.Count > 0) return ((Key)(((DynamicEntity)collection.BusinessEntities[0]).Properties["relationshiproleid"])).Value; else return Guid.Empty; } private static Guid[] GetJointBuyerId(ICrmService service, Guid opportunityId) { Guid jointBuyerRelationshipRoleId = GetJointBuyerRelationshipRoleId(service); #region Setup Conditions FilterExpression filter = new FilterExpression(); // Condition 1 - Matched opportunityid - LCY ConditionExpression condition1 = new ConditionExpression(); condition1.AttributeName = "opportunityid"; condition1.Operator = ConditionOperator.Equal; condition1.Values = new object[] { opportunityId }; filter.Conditions.Add(condition1); // Condition 2 - Matched relationshiproleid - LCY ConditionExpression condition2 = new ConditionExpression(); condition2.AttributeName = "opportunityroleid"; condition2.Operator = ConditionOperator.Equal; condition2.Values = new object[] { jointBuyerRelationshipRoleId }; filter.Conditions.Add(condition2); // Combine all conditions into filter - LCY filter.FilterOperator = LogicalOperator.And; #endregion BusinessEntityCollection collection = ToolkitHelper.RetrieveMultiple(service, new string[] { "customerid" }, RegisteredEntityName.CustomerOpportunityRole, filter); List<Guid> result = new List<Guid>(); if (collection.BusinessEntities.Count > 0) { foreach (BusinessEntity customer in collection.BusinessEntities) { if (((Customer)((DynamicEntity)customer).Properties["customerid"]).type == RegisteredEntityName.Contact) { result.Add(((Customer)((DynamicEntity)customer).Properties["customerid"]).Value); } } } return result.ToArray(); } } }
Tuesday, December 2, 2014 4:02 AM
All replies
-
Hi,
I dont think there are any direct tools available. Plugins as such dont need much change except for some methods and library change.
Check the below link:
http://www.nalashaa.com/migration-crm-4-0-dynamics-crm-2013/
You can use the Legacy feature check tool to find out the issues.
Hope this helps,
Thanks,
Prasad,
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.
Tuesday, December 2, 2014 5:07 AM -
Hi,
Yes, You need to use the CRM 2013 DLL like: Microsoft.Crm.Sdk.Proxy, Microsoft.Xrm.Sdk etc.
You can check the syntax change between CRM 4.0 and CRm 2013 plugin. CRM 2011 and CRM 2013 has same symtax.
http://weblogs.asp.net/gayanperera/5-syntax-changes-in-dynamics-crm-2011-plugins
http://msdn.microsoft.com/en-in/library/gg334459.aspx#Plugins
http://www.powerobjects.com/blog/2013/10/07/legacy-feature-check-tool-prepare-crm-2013/For RetrieveMultiple you can refer MSDN.
http://msdn.microsoft.com/en-in/library/gg328149.aspx
Thanks!
- Proposed as answer by Kalim Khan Wednesday, December 3, 2014 5:29 AM
Tuesday, December 2, 2014 6:17 AM