Click here to Skip to main content
15,889,754 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,



I have 2 lists in my SharePoint site one named Task List and other Store Details.



Using Jquery what I have done is on selecting a store from dropdown in Task List,other fields like Region Manager(People/group),Store Manager(People/group) values are fetched from Lookup list Store Details and auto populated there.



The problem is the value doesn't get saved until we click on that People picker control,validate it.



I want these things to happen automatically using jquery and the people picker to be non editable



Thanks

Arvind
Posted
Comments
Sampath Lokuge 27-Apr-14 0:58am    
Can you put your code snippet which you have done so far ?
Arvind Jha 28-Apr-14 7:29am    
<script language="javascript" type="text/javascript" src="/SiteAssets/jQueryLibrary/jquery-1.6.min.js"></script>
<script language="javascript" type="text/javascript" src="/SiteAssets/jQueryLibrary/jquery.SPServices-0.7.2.min.js"></script>
<script language="javascript" type="text/javascript">
var sText;

$(document).ready(function () {

$("select[title$='Store Name']").change(function () {


sText = $("select[title$='Store Name'] option:selected").text();

search();





});
});

function search(){
var context = new SP.ClientContext.get_current();
var web = context.get_web();
var list = web.get_lists().getByTitle('Store Details');
var query = '<view> <query><where><eq><fieldref name="\'Title\'/"><value type="\'Text\'">' + sText + '';
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml(query);
this.collListItems = list.getItems(camlQuery);
context.load(this.collListItems);
context.executeQueryAsync(Function.createDelegate(this, this.onSuccess), Function.createDelegate(this, this.onFail));
}

function onSuccess(){
var listEnumerator=this.collListItems.getEnumerator();
while (listEnumerator.moveNext())
{
var item = listEnumerator.get_current();

$("input[title$='Region Name']").val(item.get_item('Region_x0020_Name'));
$("input[title$='District Name']").val(item.get_item('District_x0020_Name'));
$("input[title$='Region Name']").attr("disabled", "disabled");
$("input[title$='District Name']").attr("disabled", "disabled");
$("input[title$='District Manager']").val(item.get_item('District_x0020_Manager').get_lookupValue());
$("input[title$='Store Manager']").val(item.get_item('Store_x0020_Manager').get_lookupValue());
$("input[title$='Region Manager']").val(item.get_item('Region_x0020_Manager').get_lookupValue());
$("input[title$='Company Manager']").val(item.get_item('Company_x0020_Manager'));
$("input[title$='Store ManagerOld']").val(item.get_item('Store_x0020_Manager').get_lookupValue());
$("input[title$='District ManagerOld']").val(item.get_item('District_x0020_Manager').get_lookupValue());
$("input[title$='Company ManagerOld']").val(item.get_item('Company_x0020_Manager').get_lookupValue());
$("input[title$='Region Manager1']").val(item.get_item('Region_x0020_Manager').get_lookupValue()); }


}

function onFail(){
alert('');
}
</script>

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900