Get URL parameter(Request no -p*****)
Ex: http://sharepoint2013site.com/mysite/p2p/SitePages/PRStageWise2.aspx?PRNumber=N30021
Code -1
prnumberis= GetParameterValuesApprove();
Code 2
function GetParameterValuesApprove()
{
var url = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for (var i = 0; i < url.length; i++)
{
var urlparam = url[i].split('=');
if (urlparam[0] == "PRNumber")
{
return urlparam[1];
}
}
}
Person name bind to person group filed in SharePoint List?
function SubmitDsc1Details(prnumberis)
{
var prno=prnumberis;
if (validation2() == true)
{
var supplier1is =$('#DSC1sup1').val();
var supplier2is = $('#DSC1sup2').val();
var supplier3is = $('#DSC1sup3').val();
if (supplier1is != undefined)
{
var supplier1is =$('#DSC1sup1').val();
}
else
{
var supplier1is =$('#DSC1sup1').val(" ");
}
if (supplier2is != undefined)
{
var supplier2is =$('#DSC1sup2').val();
}
else
{
var supplier2is =$('#DSC1sup2').val(" ");
}
if (supplier1is != undefined)
{
var supplier3is =$('#DSC1sup3').val();
}
else
{
var supplier3is =$('#DSC1sup3').val(" ");
}
var aap1 = document.getElementById('ap1').value;
var aap2 = document.getElementById('ap2').value;
var aap3 = document.getElementById('ap3').value;
var IBudgetAmountis = parseInt(BudgetAmountis);
var status2="";
var IBudgetAmountis = parseInt(BudgetAmountis);
if(IBudgetAmountis >50000)
{
status2="Pending";
}
var clientContext = new SP.ClientContext.get_current();
var oList = clientContext.get_web().get_lists().getByTitle('DSC1');
var itemCreateInfo = new SP.ListItemCreationInformation();
this.oListItem = oList.addItem(itemCreateInfo);
oListItem.set_item('Title', prnumberis);
oListItem.set_item('Supplier1', supplier1is);
oListItem.set_item('Supplier2', supplier2is);
oListItem.set_item('Supplier3', supplier3is);
oListItem.set_item('Amount', IBudgetAmountis);
oListItem.set_item('Role', Types);
oListItem.set_item('Approver1', aap1);
oListItem.set_item('Stage', stage2is);
oListItem.set_item('Status2', status2);
//var assignedToVal3 = new SP.FieldUserValue();
//assignedToVal3.set_lookupId(VPApprover1id);
//oListItem.set_item('Approver1', assignedToVal3);
if(VPApprover2id== undefined)
{
oListItem.set_item('Approver2', aap2);
}
else
{
var assignedToVal2 = new SP.FieldUserValue();
assignedToVal2.set_lookupId(VPApprover2id);
oListItem.set_item('Approver2', assignedToVal2);
}
if(VPApprover3id== undefined)
{
oListItem.set_item('Approver3', aap3);
}
else
{
var assignedToVal3 = new SP.FieldUserValue();
assignedToVal3.set_lookupId(VPApprover3id);
oListItem.set_item('Approver3', assignedToVal3);
}
oListItem.update();
clientContext.load(oListItem);
clientContext.executeQueryAsync(Dsc1onSystemChildSucceeded(), Dsc1onSystemChildFailed);
}
}
function Dsc1onSystemChildSucceeded()
{
//console.log("DSC1 Suppliers Submitted");
alert("Supplier List Submitted");
$('#DSC1sup1').val("");
$('#DSC1sup2').val("");
$('#DSC1sup3').val("");
}
function Dsc1onSystemChildFailed(sender, args)
{
alert("Error Occured..");
console.log('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
Get People Picker set up code
code 1
initializePeoplePicker("BudgetCordinator", "", false);
initializePeoplePicker("Approvedby", "", false);
code 2
function initializePeoplePicker(peoplePickerElementId, userList, isMulti)
{
// Create a schema to store picker properties, and set the properties.
var schema = {};
schema['PrincipalAccountType'] = 'User';
schema['SearchPrincipalSource'] = 15;
schema['ResolvePrincipalSource'] = 15;
schema['AllowMultipleValues'] = isMulti;
schema['MaximumEntitySuggestions'] = 50;
schema['Width'] = '173px';
var users = new Array();
// Update to handle multiple users
for(i=0;i<userList.length;i++){
var defaultUser = new Object();
defaultUser.AutoFillDisplayText = userList[i].Title;
defaultUser.Description = userList[i].Email;
defaultUser.DisplayText = userList[i].Title;
defaultUser.EntityType = "User";
defaultUser.IsResolved = true;
defaultUser.Key = userList[i].LoginName;
defaultUser.Resolved = true;
users.push(defaultUser);
}
// Render and initialize the picker.
// Pass the ID of the DOM element that contains the picker, an array of initial
// PickerEntity objects to set the picker value, and a schema that defines
// picker properties.
SPClientPeoplePicker_InitStandaloneControlWrapper(peoplePickerElementId, users, schema);
}
code 3
function getUserInfo(pickerName)
{
var peoplePicker = null;
// Get the people picker object from the page.
if (pickerName == "BudgetCordinator"){
peoplePicker = this.SPClientPeoplePicker.SPClientPeoplePickerDict.BudgetCordinator_TopSpan;
}
if (pickerName == "Approvedby"){
peoplePicker = this.SPClientPeoplePicker.SPClientPeoplePickerDict.Approvedby_TopSpan;
}
// Get information about all users.
var users = peoplePicker.GetAllUserInfo();
var keys = peoplePicker.GetAllUserKeys();
var finalusers = new Array();
for (var i = 0; i < users.length; i++) {
var arryuser = users[i];
finalusers.push(SP.FieldUserValue.fromUser(arryuser.Key));
}
return finalusers;
}
code 4 - get people pciker data bind to Div id.
var BudgetCordinator= $('#BudgetCordinator').val();
var BudgetCordinatorPOC = getUserInfo("BudgetCordinator");
var Approvedby = $('#Approvedby').val();
var ApproverPOC = getUserInfo("Approvedby");
if(BudgetCordinatorPOC == "")
{
alert("Please enter BudgetCordinator Name")
return;
}
if(ApproverPOC == "")
{
alert("Please enter Approver Name")
return;
}
add reference in Content Editor Webpart HTML?
<head>
<link rel="stylesheet" href="/ndi/p2p/SiteAssets/Css/PRStageWise.css">
<script type="text/javascript" src="../SiteAssets/JS/jquery.min.js"></script>
<script type="text/javascript" src="../SiteAssets/JS/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="../SiteAssets/JS/jquery.table2excel.min.js"></script>
<script type="text/javascript" src="_layouts/15/clienttemplates.js"></script>
<script type="text/javascript" src="_layouts/15/clientforms.js"></script>
<script type="text/javascript" src="_layouts/15/clientpeoplepicker.js"></script>
<script type="text/javascript" src="_layouts/15/autofill.js"></script>
<script src="/ndi/p2p/SiteAssets/JS/PRStageWisea.js"></script>
<script src="/ndi/p2p/SiteAssets/JS/PRStageWise2a.js"></script>
<script src="/ndi/p2p/SiteAssets/JS/TechnicalAlignment2.js"></script>
<script src="/ndi/p2p/SiteAssets/JS/DSC2a.js"></script>
<script type="text/javascript" src="/abc/p*p/SitePages/_layouts/15/sp.runtime.js"></script>
<script type="text/javascript" src="/abc/p*p/SitePages/_layouts/15/sp.js"></script>
Ex: http://sharepoint2013site.com/mysite/p2p/SitePages/PRStageWise2.aspx?PRNumber=N30021
Code -1
prnumberis= GetParameterValuesApprove();
Code 2
function GetParameterValuesApprove()
{
var url = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for (var i = 0; i < url.length; i++)
{
var urlparam = url[i].split('=');
if (urlparam[0] == "PRNumber")
{
return urlparam[1];
}
}
}
Person name bind to person group filed in SharePoint List?
function SubmitDsc1Details(prnumberis)
{
var prno=prnumberis;
if (validation2() == true)
{
var supplier1is =$('#DSC1sup1').val();
var supplier2is = $('#DSC1sup2').val();
var supplier3is = $('#DSC1sup3').val();
if (supplier1is != undefined)
{
var supplier1is =$('#DSC1sup1').val();
}
else
{
var supplier1is =$('#DSC1sup1').val(" ");
}
if (supplier2is != undefined)
{
var supplier2is =$('#DSC1sup2').val();
}
else
{
var supplier2is =$('#DSC1sup2').val(" ");
}
if (supplier1is != undefined)
{
var supplier3is =$('#DSC1sup3').val();
}
else
{
var supplier3is =$('#DSC1sup3').val(" ");
}
var aap1 = document.getElementById('ap1').value;
var aap2 = document.getElementById('ap2').value;
var aap3 = document.getElementById('ap3').value;
var IBudgetAmountis = parseInt(BudgetAmountis);
var status2="";
var IBudgetAmountis = parseInt(BudgetAmountis);
if(IBudgetAmountis >50000)
{
status2="Pending";
}
var clientContext = new SP.ClientContext.get_current();
var oList = clientContext.get_web().get_lists().getByTitle('DSC1');
var itemCreateInfo = new SP.ListItemCreationInformation();
this.oListItem = oList.addItem(itemCreateInfo);
oListItem.set_item('Title', prnumberis);
oListItem.set_item('Supplier1', supplier1is);
oListItem.set_item('Supplier2', supplier2is);
oListItem.set_item('Supplier3', supplier3is);
oListItem.set_item('Amount', IBudgetAmountis);
oListItem.set_item('Role', Types);
oListItem.set_item('Approver1', aap1);
oListItem.set_item('Stage', stage2is);
oListItem.set_item('Status2', status2);
//var assignedToVal3 = new SP.FieldUserValue();
//assignedToVal3.set_lookupId(VPApprover1id);
//oListItem.set_item('Approver1', assignedToVal3);
if(VPApprover2id== undefined)
{
oListItem.set_item('Approver2', aap2);
}
else
{
var assignedToVal2 = new SP.FieldUserValue();
assignedToVal2.set_lookupId(VPApprover2id);
oListItem.set_item('Approver2', assignedToVal2);
}
if(VPApprover3id== undefined)
{
oListItem.set_item('Approver3', aap3);
}
else
{
var assignedToVal3 = new SP.FieldUserValue();
assignedToVal3.set_lookupId(VPApprover3id);
oListItem.set_item('Approver3', assignedToVal3);
}
oListItem.update();
clientContext.load(oListItem);
clientContext.executeQueryAsync(Dsc1onSystemChildSucceeded(), Dsc1onSystemChildFailed);
}
}
function Dsc1onSystemChildSucceeded()
{
//console.log("DSC1 Suppliers Submitted");
alert("Supplier List Submitted");
$('#DSC1sup1').val("");
$('#DSC1sup2').val("");
$('#DSC1sup3').val("");
}
function Dsc1onSystemChildFailed(sender, args)
{
alert("Error Occured..");
console.log('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
Get People Picker set up code
code 1
initializePeoplePicker("BudgetCordinator", "", false);
initializePeoplePicker("Approvedby", "", false);
code 2
function initializePeoplePicker(peoplePickerElementId, userList, isMulti)
{
// Create a schema to store picker properties, and set the properties.
var schema = {};
schema['PrincipalAccountType'] = 'User';
schema['SearchPrincipalSource'] = 15;
schema['ResolvePrincipalSource'] = 15;
schema['AllowMultipleValues'] = isMulti;
schema['MaximumEntitySuggestions'] = 50;
schema['Width'] = '173px';
var users = new Array();
// Update to handle multiple users
for(i=0;i<userList.length;i++){
var defaultUser = new Object();
defaultUser.AutoFillDisplayText = userList[i].Title;
defaultUser.Description = userList[i].Email;
defaultUser.DisplayText = userList[i].Title;
defaultUser.EntityType = "User";
defaultUser.IsResolved = true;
defaultUser.Key = userList[i].LoginName;
defaultUser.Resolved = true;
users.push(defaultUser);
}
// Render and initialize the picker.
// Pass the ID of the DOM element that contains the picker, an array of initial
// PickerEntity objects to set the picker value, and a schema that defines
// picker properties.
SPClientPeoplePicker_InitStandaloneControlWrapper(peoplePickerElementId, users, schema);
}
code 3
function getUserInfo(pickerName)
{
var peoplePicker = null;
// Get the people picker object from the page.
if (pickerName == "BudgetCordinator"){
peoplePicker = this.SPClientPeoplePicker.SPClientPeoplePickerDict.BudgetCordinator_TopSpan;
}
if (pickerName == "Approvedby"){
peoplePicker = this.SPClientPeoplePicker.SPClientPeoplePickerDict.Approvedby_TopSpan;
}
// Get information about all users.
var users = peoplePicker.GetAllUserInfo();
var keys = peoplePicker.GetAllUserKeys();
var finalusers = new Array();
for (var i = 0; i < users.length; i++) {
var arryuser = users[i];
finalusers.push(SP.FieldUserValue.fromUser(arryuser.Key));
}
return finalusers;
}
code 4 - get people pciker data bind to Div id.
var BudgetCordinator= $('#BudgetCordinator').val();
var BudgetCordinatorPOC = getUserInfo("BudgetCordinator");
var Approvedby = $('#Approvedby').val();
var ApproverPOC = getUserInfo("Approvedby");
if(BudgetCordinatorPOC == "")
{
alert("Please enter BudgetCordinator Name")
return;
}
if(ApproverPOC == "")
{
alert("Please enter Approver Name")
return;
}
add reference in Content Editor Webpart HTML?
<head>
<link rel="stylesheet" href="/ndi/p2p/SiteAssets/Css/PRStageWise.css">
<script type="text/javascript" src="../SiteAssets/JS/jquery.min.js"></script>
<script type="text/javascript" src="../SiteAssets/JS/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="../SiteAssets/JS/jquery.table2excel.min.js"></script>
<script type="text/javascript" src="_layouts/15/clienttemplates.js"></script>
<script type="text/javascript" src="_layouts/15/clientforms.js"></script>
<script type="text/javascript" src="_layouts/15/clientpeoplepicker.js"></script>
<script type="text/javascript" src="_layouts/15/autofill.js"></script>
<script src="/ndi/p2p/SiteAssets/JS/PRStageWisea.js"></script>
<script src="/ndi/p2p/SiteAssets/JS/PRStageWise2a.js"></script>
<script src="/ndi/p2p/SiteAssets/JS/TechnicalAlignment2.js"></script>
<script src="/ndi/p2p/SiteAssets/JS/DSC2a.js"></script>
<script type="text/javascript" src="/abc/p*p/SitePages/_layouts/15/sp.runtime.js"></script>
<script type="text/javascript" src="/abc/p*p/SitePages/_layouts/15/sp.js"></script>
No comments:
Post a Comment