Microsoft Dynamics CRM更新数字字段来自另一个实体

发布于 2025-01-23 01:46:48 字数 1697 浏览 5 评论 0原文

谁能帮助我使用JS代码,可以在记录创建期间更新一个数字?

例如:您有一个实体调用 car 具有数字值“ 当前里程”,而另一个称为 lental 的实体,该实体已提交两个数字汽车部分(当前里程接收里程)。

当前里程将存储选定汽车的里程值(示例300),接收里程将由销售人员手动输入(用于示例100)。

因此,当销售人员创建了新的租金记录,并且在这种情况下,当前里程将显示销售人员的当前行驶里程(300),因此他只是将需要添加新值(100)。下次他创建租金并从相同的汽车中选择租赁时,当前的里程将带有400(300+100),依此类推。

我认为这是对汽车查找的jscript on uupdate提起的,但我真的不知道如何编写这样的代码,希望有人可以给我一个提示。我计划遵循同一逻辑来重用其他实体的代码。

我在Dynamics CRM中具有以下JS代码,请在更改的更改中:

new_car-(查找)从租赁实体中选择一辆汽车 new_cars-汽车实体的架构名称 new_carsid-汽车实体的汽车UUID new_totally_used-汽车的总里程 new_outonoging_value-在租赁记录上提交,在选择汽车时必须出现完全使用的值

    function retrieveCarsDetails() {
//read lookup value
if (Xrm.Page.getAttribute("new_car").getValue() != null && Xrm.Page.getAttribute("new_car").getValue()[0].id != null) {
  var new_carsid = Xrm.Page.getAttribute("new_car").getValue()[0].id;
new_carsid=new_carsid.replace('{','').replace('}','');
  //pass entity, fields, we can use expand to get related entity fields
  Xrm.WebApi.retrieveRecord("new_cars", new_carsid, "?$select=new_totally_used").then(
    function success(result) {
      if (result != null) {
        //set text field
        if (result["new_outgoing_value"] != null)
          Xrm.Page.getAttribute("new_totally_used").setValue(result["new_outgoing_value"]);
      }
    },
    function(error) {
      alert(error.message);
    }
  );
}
}

Can anyone help me with a JS code where I can update a number filed during a record creation?

For example: You have an entity call cars that have a number value "current mileage" and another entity called rental that has two number filed for car section (current mileage and received mileage).

Current mileage will store the mileage value of the selected car (example 300) and the received mileage will be manually inputted by the sales person (for example 100).

So when the sale person created a new rental record, and OnUpdate of the Car lookup field the Current mileage will show the sales person the current mileage of the selected car (300) in this case, so he just will need to add the new value (100). Next time when he create a rental and select from the looup the same car, the Current mileage will be populated with 400 (300+100), and so on.

I see this as JScript OnUpdate of the Car lookup filed, but i really dont know how to write such a code, i hope someone can give me a hint. I'm planning to reuse the code for other entities following the same logic.

I have the following JS code in DYnamics CRM attached on change of a lookupfiled:

new_car - (lookup) to select a car from the rental entity
new_cars - schema name of the cars entity
new_carsid - UUID of the car from the car entity
new_totally_used - total mileage of a car
new_outgoing_value - filed on the rental record where must the totally used value appears upon selection of a car

    function retrieveCarsDetails() {
//read lookup value
if (Xrm.Page.getAttribute("new_car").getValue() != null && Xrm.Page.getAttribute("new_car").getValue()[0].id != null) {
  var new_carsid = Xrm.Page.getAttribute("new_car").getValue()[0].id;
new_carsid=new_carsid.replace('{','').replace('}','');
  //pass entity, fields, we can use expand to get related entity fields
  Xrm.WebApi.retrieveRecord("new_cars", new_carsid, "?$select=new_totally_used").then(
    function success(result) {
      if (result != null) {
        //set text field
        if (result["new_outgoing_value"] != null)
          Xrm.Page.getAttribute("new_totally_used").setValue(result["new_outgoing_value"]);
      }
    },
    function(error) {
      alert(error.message);
    }
  );
}
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

娇妻 2025-01-30 01:46:48

您可以在租赁实体中创建一个新字段(当前和接收的里程)。当销售人员更新接收里程时,更新此新的总字段。

因此,当在汽车实体中选择查找时,请从租赁实体中检索总和字段,并使用租赁实体的总和字段更新汽车实体的当前里程。

You can create a new field(sum of current and received mileage) in the Rental entity. Update this new sum field, when the sales person updates the received mileage.

So, when the lookup is selected in the car entity, retrieve the sum field from the Rental entity and update the Current mileage in the Car entity with Sum field of Rental entity.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文