var traderList = 'Trader/Approver';var approversList = 'Approval Limits';
NWF.FormFiller.Events.RegisterAfterReady(function()
{
NWF$('.ip-container').eq(0).addClass('ip-container nf-filler-highlightonvalidationerror ip-disabled');
NWF$('.ip-container').eq(0).attr('style','background-color: #dedede !important; border:none !important;height:28px');
NWF$('#'+approverType).attr('style', 'background-color: #dedede !important; border:none !important;width:458px;height:28px');
NWF$('#'+approverType).prop("readonly", true); NWF$('#'+traderDdl).change(function()
{
var id = NWF$('#'+traderDdl).val().split(';')[0];
GetManagerOfTrader(id);
});
});
var items;
function GetManagerOfTrader(Id)
{
var ctx = new SP.ClientContext.get_current();
var list = ctx.get_web().get_lists().getByTitle(traderList);
var camlQuery = new SP.CamlQuery();
var query = "<View><Query><Where><Eq><FieldRef Name='ID'/><Value Type='Number'>"+Id+"</Value></Eq></Where></Query></View>";
camlQuery.set_viewXml(query);
items = list.getItems(camlQuery);
ctx.load(items);
ctx.executeQueryAsync(OnSuccess,Onfail);
}
function OnSuccess()
{
var count = items.get_count();
if(count > 0)
{
var listItems = items.getEnumerator();
while(listItems.moveNext())
{
var item = listItems.get_current();
var managerName = item.get_item("Approver").get_lookupValue();
var managerId = item.get_item("Approver").get_lookupId();
// var approvertype = item.get_item("ApproverTypeLabel");
var managerId = item.get_item("Approver").get_lookupId();
var traderId = item.get_item("Trader").get_lookupId();
var AppType = item.get_item("Approver_x0020_Type").get_lookupValue();
// NWF$('#'+FirstApprover).prop("readonly", true);
var approverPicker = new NF.PeoplePickerApi('#' + FirstApprover);
approverPicker.clear();
// RemoveOtherAppInApp1Field();
var waitscreen = SP.UI.ModalDialog.showWaitScreenWithNoClose('Working on it...');
approverPicker.search(managerName).done(function (data) {
//add line manager to people picker field
approverPicker.clear();
approverPicker.add(data[0]);
waitscreen.close(0);
NWF$('.ip-item span div').eq(1).removeClass('ip-close');
});
NWF$('#'+approverType).val(AppType); NWF$('#'+traderIdtext).val(traderId);
}
}
}
function Onfail()
{}
function RemoveOtherAppInApp1Field()
{
var len = NWF$('.ip-disabled div.ip-item').length;
if(len > 0)
{
for(var i=0;i<len;i++)
{
NWF$('.ip-disabled div.ip-item').eq(i).remove();
}
}
}
No comments:
Post a Comment