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.
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..