简体   繁体   English

Dynamics CRM 2013:是否基于其他记录设置默认字段值?

[英]Dynamics CRM 2013: Set default field value based on other records?

I'm new to CRM but I'm finding my feet quickly. 我是CRM的新手,但是很快就发现了自己的脚步。

I want to set a default value in a new record - easy enough to do with business rules, however, I need to incorporate a lookup to other records as well. 我想在新记录中设置一个默认值-足以轻松处理业务规则,但是,我还需要将查找合并到其他记录中。

Basically, I want my "storeID" field to be a six digit number like 300401. I need this number to be made of the 4 digit post (zip) code (Australia) and a two digit sequential number. 基本上,我希望我的“ storeID”字段是一个六位数的数字,例如300401。我需要此数字由4位数的邮政编码(Australia)和两位数字的序号组成。 In my case, I am the only store in postcode 3004, but if I was the second store to join the business my store ID would be 300402. 就我而言,我是唯一一家邮政编码为3004的商店,但是如果我是第二家加入该业务的商店,那么我的商店ID将为300402。

Assuming the postcode field is set to be required on my entity, my logic will be: 假设将邮政编码字段设置为对我的实体是必需的,那么我的逻辑将是:

  • var pCode = postcode var pCode =邮政编码
  • var seqNo = 1 var seqNo = 1
  • if not exists record with storeID = pCode+seqNo then storeID = pCode+seqNo 如果不存在带有storeID = pCode + seqNo的记录,则storeID = pCode + seqNo
  • else loop until not exists record with storeID = pCode+seqNo with the step being seqNo + 1 then use the stepped pCode+right('00' + seqNo, 2) as the storeID else循环直到不存在storeID = pCode + seqNo的记录(步骤为seqNo +1),然后使用步进式pCode + right('00'+ seqNo,2)作为storeID

I'm assuming this is too complex for the Business Rules GUI, but what code customisations do I have - particularly with querying existing records to get that sequence number? 我以为这对于业务规则GUI来说太复杂了,但是我有哪些代码自定义项?特别是在查询现有记录以获取该序列号时?

Many thanks, 非常感谢,

Warren 沃伦

Since you are using CRM 2013 this could likely be a nice solution: 由于您使用的是CRM 2013,因此这可能是一个不错的解决方案:

http://niiranen.eu/crm/2013/12/auto-numbering-workflows-real-time-vs-asynchronous/ http://niiranen.eu/crm/2013/12/auto-numbering-workflows-real-time-vs-asynchronous/

However there are also a number of add-ons that can be found for both CRM 2011 and CRM 2013 by searching for "CRM Autonumber". 但是,通过搜索“ CRM自动编号”,也可以找到CRM 2011和CRM 2013的许多附加组件。

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

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