Plug-In Executing Multiple times and creating duplicate records
-
donderdag 31 mei 2012 0:27
Dear All,
Iam new to mscrm 2011.I implemented a plugin that creates a new record when i clicked on custom ribbon button.The record was created and also it was creating an additional duplicated record for that record.Please help me out of this context.
Iam using the following code:
Entity Inventory = new Entity(); Inventory.LogicalName = "new_inventory"; Inventory.Attributes.Add("new_locationid", new EntityReference("new_location", LocationID)); Inventory.Attributes.Add("new_divisionid", new EntityReference("new_department", DivisionID)); Inventory.Attributes.Add("new_productid", new EntityReference("new_choiceproduct", ProductID)); Inventory.Attributes.Add("new_copfid",new EntityReference("new_copf",COPFID)); Inventory.Attributes.Add("new_customernameid",new EntityReference("account",CustomerNameID)); Inventory.Attributes.Add("new_inventoryproductid", new EntityReference("new_copforderline", OrderlineID)); Inventory.Attributes.Add("new_ponumber", PONumber); Inventory.Attributes.Add("new_invoicenumber", InvNumber); Inventory.Attributes.Add("new_copfnumber", COPFNumber); OptionSetValue Option1 = new OptionSetValue(100000000); Inventory.Attributes.Add("new_type", Option1); OptionSetValue Option2 = new OptionSetValue(100000001); Inventory.Attributes.Add("new_vouchertype", Option2); //Inventory.Attributes.Add("new_inventorystatus", "1"); Inventory.Attributes.Add("new_vchtype", "Reverse Inventory"); Inventory.Attributes.Add("new_price", Price); Inventory.Attributes.Add("new_flag", "4"); OptionSetValue Option3 = new OptionSetValue(Convert.ToInt32(InventoryInOut)); //Inventory.Attributes.Add("new_inventotyinout", Option3); Inventory.Attributes.Add("new_remarks", "Inventory Revert Back"); int Qty = (Quantity) * (-1); Inventory.Attributes.Add("new_quantity", Qty); Inventory.Attributes.Add("new_remainingquantity", Qty); //throw new InvalidPluginExecutionException(Qty.ToString()); if (context.Depth == 1) { service.Create(Inventory); }
Alle reacties
-
donderdag 31 mei 2012 5:00Moderator
Hi,
Are you sure there is only one plugin only no other workflow/javacript ????? and have you enabled duplicate detection ??
Mahain : Check My Blog
Follow me on Twitter
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question. -
donderdag 31 mei 2012 7:03
HI Srikanth A,
What are the sdk Message processing steps you registered this plugin? For what entity and event is it registered? When you click on the button from the ribbon, are you also creating the inventory record to fire the plugin?
Regards,
Damian Sinay