0

One of the JSOM solutions I am working on, I am alerting the SharePoint choice column value upon change. I have a list called Asset List (collaboration list) with four columns: Title, Stage(Choice column with choices: Development, Transition and Property), Asset Link (Hyperlink type column) and Asset Description. Please see below screenshot for reference

Asset List

So right now using below code I am able to catch and alert when a stage choice column value changes.

<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script type="text/javascript">

$(document).ready(function() {  
$("select[title='Stage']").change(function() {  

          var stage = $("select[title='Stage']").val();  

alert(stage);       


});
});
</script>

Now the next challenging step is when the stage value changes for e.g. from Development to transition then I also want to get the list item id or ID(metadata column value for that change) and the URL value from the Asset Link column.I have to pass either ID or ListItemID and also the URL value into couple of functions so need to capture them when a stage value changes. I am using JSOM and working with office 365/SharePoint online. If any one has an idea, please help.

0

You can use the following code to get item ID and the URL value of the Asset Link column:

<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script type="text/javascript">

$(document).ready(function() {  
$("select[title='Stage']").change(function() {  
    var stage = $("select[title='Stage']").val(); 
    alert(stage);
    var itemID = getParameterByName('ID'); 
    alert(itemID);     
    var URL = $("input[id^='Asset_x0020_Link']").val();
    alert(URL);

});
});

function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
        results = regex.exec(location.search);
    return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}

</script>

The result is: enter image description here enter image description here enter image description here

0

You can use this one

<script type="text/javascript" src="https://code.jquery.com/jquery- 
1.12.4.js"></script>
<script src="/jquery.SPServices-2013.02a.js" type="text/javascript"> 
</script>
<script type="text/javascript">

 $(document).ready(function() {  
 $("select[title='Stage']").change(function() {  
   var itemid = GetUrlKeyValue("ID") 
   var stage = $("select[title='Stage']").val(); 
   var AssetLink = $("input[id^='AssetLink']").val();
     alert("Stage: " + stage + "\n" +  " ID: " + itemid + "\n" + "Asset 
           Link: " + AssetLink); 
});
});
</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.