从另一个应用程序以编程方式创建任务? [英] Creating a task programmatically from another application?

查看:86
本文介绍了从另一个应用程序以编程方式创建任务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过编程或API来c 创建和保存任务?来自另一个应用程序?

Is there a way to create and save a task programmatically or via an API? from another application?

我们当前有一个可以从SharePoint(2013)的任务管理功能中受益的应用程序.

We currently have an application which would benefit from the tasks management features of SharePoint (2013).

我们已经成功实现了通过URL创建任务的工作,该任务通过将参数传递给URL来自动填充任务表单中的各个字段.这要求用户在任务表单中单击保存",该表单将任务发布到SharePoint中.

We have already successfully implemented creating a task via URL which auto populates various fields in the task form by passing parameters to the URL.  This requires the user to click Save in the task form which posts the task in SharePoint.

由于可能存在许多这样的任务,是否有可能以编程方式或通过后台的其他应用程序中的API创建和保存任务?

Since there is a potential to have many of these tasks, is it possible to create and save tasks programmatically or via an API from another application behind the scenes?

推荐答案

我们可以使用CSOM来实现它.

We can use CSOM to achieve it.

这是一个简单的演示供您参考.

Here is a simple demo for your reference.

            string siteURL = http://sp/sites/DevSite;           
            ClientContext context = new ClientContext(siteURL);            

            //set credential of SharePoint Server(on-premise)
            context.Credentials = new NetworkCredential("spsvc", "Access1", "CONTOSO");
            Web web = context.Web;
            List list = context.Web.Lists.GetByTitle("MyTask");

            context.Load(list);
            context.Load(web);
            context.ExecuteQuery();

            ListItemCreationInformation listItemCreation = new ListItemCreationInformation();
            ListItem task = list.AddItem(listItemCreation);
            User user = web.EnsureUser("CONTOSO\\spsvc");
            context.Load(user);
            context.ExecuteQuery();

            task["Title"] = "Testing";
            task["Body"] = "Testing Body";
            task["StartDate"] = "2018-1-30";
            task["DueDate"] = "2018-1-31";
            task["AssignedTo"] = user;
            task.Update();
            context.ExecuteQuery();
                              

结果的屏幕截图.

更多信息供您参考.

http://it-mathy.blogspot.sg/2013 /05/creating-sharepoint-task-using-client.html

最诚挚的问候,

刘李


这篇关于从另一个应用程序以编程方式创建任务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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