自定义列表表单 - 自动填充管理器

发布于 2024-09-06 08:38:52 字数 519 浏览 2 评论 0原文

我有一个 Sharepoint 2007 自定义列表,其中有一列名为“经理”,用于保存用户的经理(单行文本)。

创建新项目时,我希望 NewForm.aspx 使用用户的经理自动计算“经理”字段。

我知道我们可以使用 JQuery 自动计算列表表单字段,以访问作为 Web 服务公开的 Sharepoint 的“用户信息列表”,如下面 Marc 的博客所示:

http://sympmarc.com/2010/04/29/populate-a-sharepoint-list-form-with -the-current-user-information/

我的问题是管理器没有存储在“用户信息列表”中,所以我无法像上面那样检索它,有人有什么想法吗?

谢谢,导航

I have a Sharepoint 2007 custom list with a column named 'Manager', to hold the user's Manager (single line of text).

When creating a new item I want the NewForm.aspx to autopulate the Manager field with the user's manager.

I know we can autopulate list form fields using JQuery to access Sharepoint's 'User Information List' exposed as a webservice, as Marc's blog below:

http://sympmarc.com/2010/04/29/populating-a-sharepoint-list-form-with-the-current-user-information/

My problem is the Manager is not stored in the 'User Information List' so I can not retrieve it as above, anyone have any ideas?

Thanks, Nav

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

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

发布评论

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

评论(1

一梦等七年七年为一梦 2024-09-13 08:38:52

这很简单,您需要在“listName”下面声明“CAMLQuery”、“CAMLRowLimit”和“CAMLViewFields”,我将用下一个代码示例对此进行解释:

您可以从列表视图中获取 CAMLQuery,在sharepoint Designer打开一个表单,我打开我的视图列表anuncio.aspx并找到下一个代码:

<View Name="your list name">
<Query> 
<OrderBy>
        <FieldRef Name="Title" Ascending="FALSE"/>
</OrderBy>
    </Query>
<ViewFields>
    <FieldRef Name="Title"/>
    <FieldRef Name="Body"/>
    <FieldRef Name="Expires"/>
</ViewFields>
    <RowLimit Paged="TRUE">30</RowLimit>
    <Toolbar Type="Standard"/>
</View>

然后根据您的需要或视图列表的查询在您的JavaScript代码中拆分查询caml,

   var fields ="<ViewFields>"+
        "<FieldRef Name='Title'/>"+
        "<FieldRef Name='Body'/>"+
        "<FieldRef Name='Expires'/>"+
          "</ViewFields>";
   var query = "<Query>"+ 
             "<OrderBy>"+
               "<FieldRef Name='Modified' Ascending='FALSE'/>"+
             "</OrderBy>"+
               "</Query>";

在变量中设置CAMLQuery后,修改你的脚本:

    $(document).ready(function() {


       $().SPServices({
         operation: "GetListItems",
         async: false,
         listName: "Your List name",

         CAMLViewFields: fields,
            CAMLQuery: query,   


            completefunc: function (xData, Status) {

             $(xData.responseXML).SPFilterNode("z:row").each(function() {

                var liHtml = "<tr> <td>" + $(this).attr("ows_Title") + "</td> </tr>";


                 $("#tasksUL").append(liHtml);

        });
      }
    });


   });


   </script>
   <table id="tasksUL"/>

It's very easy, you need to declare a "CAMLQuery", "CAMLRowLimit" and "CAMLViewFields" below of "listName", I'll explain this with the next code example:

You can get your CAMLQuery from a view of you list, in sharepoint Designer open a form, I opened the my view list anuncio.aspx and found the next code:

<View Name="your list name">
<Query> 
<OrderBy>
        <FieldRef Name="Title" Ascending="FALSE"/>
</OrderBy>
    </Query>
<ViewFields>
    <FieldRef Name="Title"/>
    <FieldRef Name="Body"/>
    <FieldRef Name="Expires"/>
</ViewFields>
    <RowLimit Paged="TRUE">30</RowLimit>
    <Toolbar Type="Standard"/>
</View>

Then split the query caml in your JavaScript code depends of your needs or query of your view list,

   var fields ="<ViewFields>"+
        "<FieldRef Name='Title'/>"+
        "<FieldRef Name='Body'/>"+
        "<FieldRef Name='Expires'/>"+
          "</ViewFields>";
   var query = "<Query>"+ 
             "<OrderBy>"+
               "<FieldRef Name='Modified' Ascending='FALSE'/>"+
             "</OrderBy>"+
               "</Query>";

After set the CAMLQuery in the variables, modify your script:

    $(document).ready(function() {


       $().SPServices({
         operation: "GetListItems",
         async: false,
         listName: "Your List name",

         CAMLViewFields: fields,
            CAMLQuery: query,   


            completefunc: function (xData, Status) {

             $(xData.responseXML).SPFilterNode("z:row").each(function() {

                var liHtml = "<tr> <td>" + $(this).attr("ows_Title") + "</td> </tr>";


                 $("#tasksUL").append(liHtml);

        });
      }
    });


   });


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