Sitecore - 自定义字段,在创建时添加独特的价值 [英] Sitecore - Custom field, add unique value on create

查看:29
本文介绍了Sitecore - 自定义字段,在创建时添加独特的价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个生成运行数字的字段.每次创建新项目时都会自动生成此编号,并且该编号必须是唯一的.

I want to create a field that generates a running number. This number will be automatically generated everytime I create a new item and has to be unique.

关于如何实现的任何示例?我不想为此使用 Sitecore 项目 ID.

Any examples of how this could be implemented? I don't want to use the Sitecore item ID for this.

推荐答案

您可以实现自定义令牌并仅使用您的字段.我认为这将是解决您问题的最干净的解决方案.您可以添加自定义算法以确保 ID 是唯一的,或者您可以只使用 Guid.NewGuid().您可以在此博文中查看如何创建自定义令牌.

You can implement a custom token and just use your field. I think this is going to be the cleanest solution for your problem. You can add your custom algorithm to guarantee that the IDs are unique or you can just use Guid.NewGuid(). You can check how to create custom tokens in this blog post.

这篇关于Sitecore - 自定义字段,在创建时添加独特的价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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