无法使用 SPD 在 Sharepoint 2013 在线自定义列表中获取查找字段值 [英] Not able to get Lookup field value in Sharepoint 2013 online Custom List Using SPD

查看:45
本文介绍了无法使用 SPD 在 Sharepoint 2013 在线自定义列表中获取查找字段值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为 "ActivityStatus" 的查找列,它有两个值.我只想检查 Presave 操作上的查找字段值.下面是我的代码,但它不起作用.

I have one lookup column named "ActivityStatus" and it has two values. and I just want to check that lookup field value on Presave Action. Below is my code but it is not working.

<script type="text/javascript">
function PreSaveAction() 
{
    alert("Inside");
    var elm = document.getElementById("ActivityStatus");
    alert(elm);
    if (elm == "Incomplete" || elm == "Inprogress")
    {
       document.getElementById("ActivityStatus").style.display='none';
       alert("Previous Activity is in Progress...");
       return false ;
    }
    else
    { 
      return true ;
    }
}
</script>

推荐答案

您获取查找值的方式行不通.

The way you are getting lookup value will not work.

您必须执行以下操作.因为它呈现为 Select 标记.

you have to do something as below. As it is rendered as a Select tag.

参考以下代码:

function PreSaveAction() 
{

    var elm = document.getElementById("plpace ID your control Here");
    var elmValue = elm.options[elm.elmectedIndex].text.trim();

    if (elmValue == "Incomplete" || elmValue == "Inprogress")
    {
       // 
       //  your other code
       //
    }
    else
    { 
      return true ;
    }
}

在变量 selectedValue 中,您将获得实际值.

Here in variable selectedValue you will get actual value.

并相应地为您的控件替换 ID..

And replace the ID accordingly for your control..

这篇关于无法使用 SPD 在 Sharepoint 2013 在线自定义列表中获取查找字段值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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