Asset tracking

//Asset tracking

Asset tracking

You have company assets you’d like to track.  Like, when the item was purchased, how much it cost at the time, who’s responsible for it.  You also wan to to ensure that any maintenance is being done on time and that there is a record of the activity; who and when

What we will do is create a list, lets call it “Assets” then create another list called “maintenance” and link the two together such that when a user clicks “Record maintenance activity” it will open our maintenance list to record our actions.

The most powerful way to do this is through a two scripts; one that passes the ID or our parent and the other that creates a new maintenance record with the ID of the parent asset.

<!--
    Name: dispParent.js
-->


<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js"></script>

<script type="text/javascript">

jQuery(document).ready(function($) {

    //get the ID for the Issue from the Query String
    var issueID = getParameterByName("ID");

    //find the element with the "Add new item" link.
    //note that if you have more than one list on your page, this just finds the first one
    //var anchorElement = $("a[title='Add a new item to this list or library.']");
     var anchorElement = $("a:contains('new item')");

    
    //modify the "Add new item" link to call the "NewItem2" function and pass in the Issue ID. 
   //Be sure to put the path to your site below. You can use relative URL to the web application or the FQDN
    $(anchorElement).attr("href","javascript:NewItem2(event,'http://odin/rotomaster/test/Lists/RecItems/NewForm.aspx?IssueID="  + issueID + "&Source=http://odin/rotomaster/test/Lists/RecLog/DispForm.aspx?ID=" + issueID + "');");
    //remove the "onclick" attribute from the anchor element as we aren't using it anymore
    $(anchorElement).removeAttr("onclick");

});

// The following function should really be put into a utility library
// with all of your commonly called functions
//
// no, I didn't write this function from scratch, I found it at
// http://stackoverflow.com/questions/901115/get-query-string-values-in-javascript
function getParameterByName(name)
{
  name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
  var regexS = "[\\?&]" + name + "=([^&#]*)";
  var regex = new RegExp(regexS);
  var results = regex.exec(window.location.href);
  if(results == null)
    return "";
  else
    return decodeURIComponent(results[1].replace(/\+/g, " "));
}

</script>




<!--
    Name: newChild.js 
    
<script type="text/javascript" src="http://odin/adpusa/SiteAssets/jquery-3.1.1.slim.min.js"></script>
-->
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js"></script>


<script type="text/javascript">

jQuery(document).ready(function($) {

    //get the Issue ID from they query string
    var issueID = getParameterByName("IssueID");
    
    //Set the corresponding Lookup field value to the Issue ID
       $("select[title='Issue']").val(issueID);    
       //use this line to disable the lookup field selection
       $("select[title='Issue']").attr('disabled','disabled')
       //use this line to hide the lookup field and label entirely
       //$("select[title='Issue']").closest("tr").hide();    
    
});

// no, I didn't write this function from scratch, I found it at
// http://stackoverflow.com/questions/901115/get-query-string-values-in-javascript
function getParameterByName(name)
{
  name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
  var regexS = "[\\?&]" + name + "=([^&#]*)";
  var regex = new RegExp(regexS);
  var results = regex.exec(window.location.href);
  if(results == null)
    return "";
  else
    return decodeURIComponent(results[1].replace(/\+/g, " "));
}

</script>
By | 2019-05-02T16:28:25+00:00 May 2nd, 2019|Uncategorized|0 Comments

About the Author:

Leave a Reply