简体   繁体   English

如何在Dynamics CRM的计算字段中使用查找字段中的货币字段

[英]how to use currency field from Lookup field in Calculated Field of Dynamics CRM

I'm setting up a new project in Dynamics crm, My entity name is "Complaint", also I have another Entity , it's Name is: "Project", and we have a "Project" Lookup field in Complaint. 我正在Dynamics crm中建立一个新项目,我的实体名称是“投诉”,另外我还有一个实体,它的名称是:“项目”,而我们在投诉中有一个“项目”查找字段。 another field of "Complaint" is "Calculated Cost"(Currency) . “投诉”的另一个字段是“计算成本”(货币)。 we need to have this formula: Calculated_Cost = Chargeable_ManHour(Decimal) * Project.ManHourCost(Currency) 我们需要使用以下公式: Calculated_Cost = Chargeable_ManHour(Decimal) * Project.ManHourCost(Currency)

but it did not work. 但它没有用。

so I check this one: Calculated_Cost = Project.ManHourCost 所以我检查一下: Calculated_Cost = Project.ManHourCost

but it did not work again. 但它再也没有起作用。

so I check another one: Calculated_Cost = Project.SomeDecimalField(Decimal) 所以我检查了另一个: Calculated_Cost = Project.SomeDecimalField(Decimal)

this one worked. 这个工作了。

I think that this problem may related to Currency DataType and may we have a Cast Function for this, anybody have a Solution for this? 我认为这个问题可能与Currency DataType有关,我们是否可以为此使用Cast函数,有人可以为此解决吗?

I bet your test record doesn't have the “Currency” lookup field set to a value. 我敢打赌,您的测试记录没有将“货币”查询字段设置为一个值。 This is a special field that is not normally shown on the form and it is added automatically the first time you add a “Currency” type field to the entity. 这是一个特殊字段,通常不会显示在表单上,​​并且在您第一次向实体中添加“货币”类型字段时会自动添加。 If you already have records in the database, those records will have a null Currency lookup field. 如果数据库中已经有记录,则这些记录将具有空的“货币”查找字段。 New records will automatically set their Currency lookup to the system Default Currency, but old records that do not have a Currency lookup set will not calculate correctly because they don't know which Currency to use (even if you only use one Currency). 新记录将自动将其货币查询设置为系统默认货币,但是没有货币查询集的旧记录将无法正确计算,因为它们不知道要使用哪种货币(即使您仅使用一种货币)。

The fix is to go back and set the Currency lookup for all existing records after you add the first Currency type field to an entity. 解决方法是在将第一个“货币类型”字段添加到实体后,返回并为所有现有记录设置“货币”查找。 You can use the multi-edit feature or a workflow (after you have added the Currency lookup to the form) or you could write a quick script to do it if you have lots of records to update. 您可以使用多重编辑功能或工作流程(将“货币”查找添加到表单后),或者如果要更新的记录很多,可以编写一个快速脚本来执行此操作。

So my theory is that you created this entity, created some test records, then you added the first Currency field (which is calculated). 所以我的理论是,您创建了这个实体,创建了一些测试记录,然后添加了第一个“货币”字段(已计算)。 Your existing test record now has a null Currency lookup, so your custom calculated Currency field cannot calculate a value. 您现有的测试记录现在具有空货币查询,因此您的自定义计算货币字段无法计算值。 You could easily test this by just creating a new test record and see if the calculation works on the new record, since the Currency lookup will be set automatically going forward. 您可以轻松地通过创建新的测试记录来进行测试,并查看计算是否适用于新记录,因为货币查询将自动进行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM