Not able to get Lookup field value in Sharepoint 2013 online Custom List Using SPD

痴心易碎 提交于 2019-12-08 11:04:26

问题


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>

回答1:


The way you are getting lookup value will not work.

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

Refer below code :

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 ;
    }
}

Here in variable selectedValue you will get actual value.

And replace the ID accordingly for your control..



来源:https://stackoverflow.com/questions/48988509/not-able-to-get-lookup-field-value-in-sharepoint-2013-online-custom-list-using-s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!