保存时更新列表内容类型 [英] Update List Content Type on Save

查看:83
本文介绍了保存时更新列表内容类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用不同的内容类型(A,B和C)创建工作流程

I am trying to create a workflow using different content types (A, B and C)

创建新的列表项将显示内容类型A的字段

Creating a new list item shows the field for Content Type A

编辑列表项将显示一个下拉字段,我可以在其中选择3种内容类型中的任何一种.我不希望这样(并且可以根据需要隐藏该字段).我想要的是一种通过用户更新特定字段或修改项目内容类型状态的方法 保存表单后(即创建简单的工作流程),以便链中的下一个人可以使用下一个内容类型表单.

Editing a list item shows a dropdown field where I can choose any of the 3 content types. I don't want this (and can hide the field if needed). What I want is a way of modifying the items content type state either by a user updating a particular field or when they have saved the form i.e. creating a simple workflow, so the next person in the chain can use the next content type form.

公司规则禁止Sharepoint设计器,所以我被困住了.

Corporate rules prohibit Sharepoint designer and so I am stuck.

我认为有两种不同的解决方法:

I think there are 2 different ways to tackle this:

1.用户更新列表字段,并且内容类型以某种方式更新,或者

1. a user updates a list field and the content type updates somehow, or

2.保存表单时,内容类型将更改为工作流中的下一个

2. when saving the form the content type changes to the next one in the workflow

推荐答案

如果您要基于列表字段隐藏/设置默认内容类型,我会建议您为此使用JSOM/jQuery.

在编辑表单中插入脚本编辑器Web部件.

通过JSOM检查项目字段值.

function getUrlVars() {
var vars = [],
    hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for (var i = 0; i < hashes.length; i++) {
    hash = hashes[i].split('=');
    vars.push(hash[0]);
    vars[hash[0]] = hash[1];
}
return vars;
}
//THEN DO THIS
var id = getUrlVars()["ID"];
//THEN DO YOUR MAGIC
var context = new SP.ClientContext(_spPageContextInfo.webServerRelativeUrl);
var list = context.get_web().get_lists().getById(_spPageContextInfo.pageListId);
var item = list.getItemById(id);

通过jQuery更新内容类型选择的值.

这里有一个线程供您参考.

https://dannyherran.com/2010/08/在选择列表中按值更改选择的选项- with-jquery/

最好的问候,


这篇关于保存时更新列表内容类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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