使用javascript和列内部名称获取sharepoint表单字段ID。 [英] Get the sharepoint form Field ID using javascript and column Internal Name.

查看:54
本文介绍了使用javascript和列内部名称获取sharepoint表单字段ID。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我一直在阅读这篇文章:  https://social.technet.microsoft.com/Forums/sharepoint/en-US/236ebd74- 8d1d-45fd-a738-24aeefd0b2d5 / get-the-sharepoint-form-field-id-using-javascript?forum = sharepointgeneralprevious

I have been reading this post: https://social.technet.microsoft.com/Forums/sharepoint/en-US/236ebd74-8d1d-45fd-a738-24aeefd0b2d5/get-the-sharepoint-form-field-id-using-javascript?forum=sharepointgeneralprevious

原因是我想得到文本框(< ;输入/>)使用列的内部名称而不是我在该帖子中读到的标题。

The reason is I would like to get the textbox (<input />) using the Internal name of the column instead the title as I have read in that post.

或有没有办法转换内部名称(例如"名字用户")来获取ID这个领域? 

or Is there any way to transfrom the Internal name (Eg. "First Name User") to get the ID of this field? 

< input type =" text"值= QUOT;" MAXLENGTH = QUOT; 25" ID = QUOT; First_x0020_Name_x0020_User12c0b2-b652-47f1-8adb-af671dabac2f_ $的TextField" title ="名字:" style =" ime-mode:" class =" ms-long ms-spellcheck-true">

<input type="text" value="" maxlength="25" id="First_x0020_Name_x0020_User12c0b2-b652-47f1-8adb-af671dabac2f_$TextField" title="First Name:" style="ime-mode : " class="ms-long ms-spellcheck-true">

谢谢!

推荐答案

如果你不这样做,你可以通过JSOM做到这一点想要在你涂抹时使用jQuery。

<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<script type="text/ecmascript" language="ecmascript">

    var fieldCollection;
    var oneField = null;
    function runCode() {
        var clientContext = SP.ClientContext.get_current();
        if (clientContext != undefined && clientContext != null) {
            var webSite = clientContext.get_web();
            taskList = webSite.get_lists().getByTitle("Tasks");

            fieldCollection = taskList.get_fields();
            this.oneField = fieldCollection.getByInternalNameOrTitle("Title");

            this.oneField.set_description("MyNewFieldDescription");
            this.oneField.update();

            clientContext.load(this.fieldCollection);
            clientContext.load(this.oneField);
            clientContext.executeQueryAsync(Function.createDelegate(this, this.OnLoadSuccess), Function.createDelegate(this, this.OnLoadFailed));
        }
    }

    function OnLoadSuccess(sender, args) {
        var fieldInfo = '';
        fieldInfo += 'Field Title: ' + oneField.get_title() + '\n' + 'Description: ' + oneField.get_description() + '\n';
        alert(fieldInfo);
    }

    function OnLoadFailed(sender, args) {
        alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
    }
</script>

    <input id="Button1" type="button" value="Run Code" onclick="runCode()" />

</asp:Content>

这是供您参考的链接。

https://docs.microsoft.com/en-us/previous-versions/office/developer/sharepoint-2010/ff409307%28v%3doffice。 14%29

最好的问候,

Lee


这篇关于使用javascript和列内部名称获取sharepoint表单字段ID。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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