adjen13198
asked on
Sharepoint 2013 - New related list item, of a specific Content Type, auto linked
We have a Sharepoint 2013 site, with lists for People, and Applications.
When we click on a person record to 'view' their person details (the default People list Display Form) - we have added a list web part to show the 'related' items from the Applications list.
The Applications list has several content types representing the different types of applications - each of which has different columns that are required.
We are currently able to click a hyperlink to open a new 'item' from the Applications list and have it pass through the related_person_id. What we are missing is how to construct the hyperlink to open a specific content type when clicked.
Here is the current script we are using to identify the person id, and then find a hyperlink, and replace it with one that appends the related_person_id field value:
<a href="javascript:NewItem2( event,' ;http://sp01/sites/eligibility/Lists/Eligibility_Applications/NewForm.aspx;);">New App</a>
<!-- Name: DisplayRelatedPeople.js -->
<script src="/sites/eligibility/De vDocs/jque ry-1.11.1. min.js" type="text/javascript"></s cript>
<script type="text/javascript">
jQuery(document).ready(fun ction($) {
//get the ID for the Issue from the Query String
var issueID = getParameterByName("ID");
//find the element with the "New Application" link.
//note that if you have more than one list on your page, this just finds the first one
var anchorElement = $("a:contains('New App')");
$(anchorElement).attr("hre f","javasc ript:NewIt em2(event, 'http://sp01/sites/eligibility/Lists/Eligibility_Applications/NewForm.aspx?Related_Person_ID=" + issueID + "');");
});
// 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].replac e(/\+/g, " "));
}
</script>
When we click on a person record to 'view' their person details (the default People list Display Form) - we have added a list web part to show the 'related' items from the Applications list.
The Applications list has several content types representing the different types of applications - each of which has different columns that are required.
We are currently able to click a hyperlink to open a new 'item' from the Applications list and have it pass through the related_person_id. What we are missing is how to construct the hyperlink to open a specific content type when clicked.
Here is the current script we are using to identify the person id, and then find a hyperlink, and replace it with one that appends the related_person_id field value:
<a href="javascript:NewItem2(
<!-- Name: DisplayRelatedPeople.js -->
<script src="/sites/eligibility/De
<script type="text/javascript">
jQuery(document).ready(fun
//get the ID for the Issue from the Query String
var issueID = getParameterByName("ID");
//find the element with the "New Application" link.
//note that if you have more than one list on your page, this just finds the first one
var anchorElement = $("a:contains('New App')");
$(anchorElement).attr("hre
});
// 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
if(results == null)
return "";
else
return decodeURIComponent(results
}
</script>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks very much for the link. I was able to get it to work!!
Much appreciated
Adam
Much appreciated
Adam
ASKER