如何通过C#在子菜单选项中添加项目-Dynamics CRM Online [英] How do I add items in the sub menu options through c# - Dynamics CRM Online

查看:85
本文介绍了如何通过C#在子菜单选项中添加项目-Dynamics CRM Online的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在有一些菜单项的机会,如下图所示.

I have an existing opportunity with some menu items as shown in the below image.

我想使用Windows窗体应用程序以编程方式添加产品.现有产品是使用Dynamics Online Portal添加的.但是,我需要通过c#进行同样的操作.

I want to programatically add the product using a windows forms application.The existing product was added using Dynamics Online Portal. But, I need to do the same via c#.

在互联网上搜索后,我发现我们可以通过使用Related Enitities&调用Service.Execute(Request).

After searching in the internet, I found out that we can achieve this by using Related Enitities & calling Service.Execute(Request).

所以首先我找到了必需的实体名称.当我找到Motor Products的实体名称时,我使用了Service.Create(entity)添加了产品.添加了该产品,但由于这次机会我没有通过参考,因此没有在该机会下显示.

So first, I found out the entity names of the required.As I found the entity name for Motor Products, I used Service.Create(entity) to add the product. The product was added but it wasn't showing under this opportunity as I didn't pass the reference for this opportunity.

然后,我尝试查找机会与产品订单项之间的关系,但找不到任何常见的唯一属性(例如:产品订单项中不存在机会ID).最终,该应用程序引发了错误.

Then, I tried to find the relation between Opportunity and Product Line Items but I couldn't find any common unique attribute (ex: opportunityid is not there in Product Line Items). Ultimately, the application was throwing errors.

有什么办法可以通过编程方式将产品添加到电机产品"中?

Is there any way we can add the product in the Motor Products programatically?

推荐答案

汽车产品下看到的网格未显示与商机相关的产品,但机会产品.

The grid you're seeing under Motor Products is not showing Products related to the Opportunity, but Opportunity Products.

机会产品是一个不同的实体,并充当机会及其相关产品之间的交集.

Opportunity Product is a different entity, and acts as an intersection between Opportunities and their associated Products.

机会产品可以用C#编程创建.这是它的外观:

Opportunity Products can be created programatically in C#. Here's how it might look:

var opportunityProduct = new Entity("opportunityproduct");
opportunityProduct["opportunityid"] = new EntityReference("opportunity", new Guid("oppId");
opportunityProduct["productid"] = new EntityReference("product", new Guid("productId");
...
var opportunityProductId = service.Create(opportunityProduct);

您正确地找到了opportunityid字段;它不在表单上,​​而是在实体的架构上.您可以检查SDK元数据文件以作证明.

You were right to look for the opportunityid field; it's not on the form but it is on the entity's schema. You can check the SDK metadata file for proof.

这篇关于如何通过C#在子菜单选项中添加项目-Dynamics CRM Online的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆