Last active
February 15, 2019 13:34
-
-
Save JoseCage/9565768a63a60017083b808c0cb0ca6a to your computer and use it in GitHub Desktop.
Preencher o País do financiador na Lista com base no País do financiador selecionado
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var PaisFincanciadorSel = $("select[title='Financiador']"); | |
PaisFincanciadorSel.change(function() { | |
populateLists(); | |
}); | |
var ListItem; | |
function populateLists() | |
{ | |
var FinanciadorTitle = $("select[title='Financiador']").val(); | |
var clientContext = new SP.ClientContext.get_current(); | |
var ClassList = clientContext.get_web().get_lists().getByTitle('Bancos'); | |
ListItem = ClassList.getItemById(FinanciadorTitle) | |
clientContext.load(ListItem); | |
clientContext.executeQueryAsync(Function.createDelegate(this,this.Succed),Function.createDelegate(this,this.Failed)); | |
} | |
function Succed(sender, args){ | |
// Salvar o País do financiador selecionado numa variavel | |
var PaisdoFinanciador = ListItem.get_item("Pa_x00ed_s"); | |
var clientContext = new SP.ClientContext.get_current(); | |
var PaisesList = clientContext.get_web().get_lists().getByTitle('Paises'); | |
// Query | |
var cmlQuery = new SP.CamlQuery(); | |
cmlQuery.set_viewXml('<View><Query><Where><Eq><FieldRef Name="Title" /><Value Type="Text">'+ PaisdoFinanciador + '</Value></Eq></Where></Query></View>'); | |
ListItem = PaisesList.getItems(cmlQuery); | |
clientContext.load(ListItem); | |
clientContext.executeQueryAsync(Function.createDelegate(this,this.SuccedPais), Function.createDelegate(this,this.Failed)); | |
} | |
function SuccedPais(sender, args){ | |
var ListItemEnumerator = ListItem.getEnumerator(); | |
while(ListItemEnumerator.moveNext()) | |
{ | |
//console.log(LItem.get_item('Title'), LItem.get_item('ID'), true, false)); | |
$('select[title="País do Financiador"]').empty(); | |
var LItem = ListItemEnumerator.get_current(); | |
$('select[title="País do Financiador"]').append(new Option(LItem.get_item('Title'), LItem.get_item('ID'), true, false)); | |
} | |
} | |
function Failed(sender, args) | |
{ | |
alert('Error. ' + args.get_message() + '\n' + args.get_stackTrace()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var PaisFincanciadorSel = $("select[title='Financiador']"); | |
PaisFincanciadorSel.change(function() { | |
populateLists(); | |
}); | |
var ListItem; | |
function populateLists() | |
{ | |
var FinanciadorTitle = $("select[title='Financiador']").val(); | |
var clientContext = new SP.ClientContext.get_current(); | |
var ClassList = clientContext.get_web().get_lists().getByTitle('Bancos'); | |
ListItem = ClassList.getItemById(FinanciadorTitle) | |
clientContext.load(ListItem); | |
clientContext.executeQueryAsync(Function.createDelegate(this,this.Succed),Function.createDelegate(this,this.Failed)); | |
} | |
function Succed(sender, args){ | |
// Salvar o País do financiador selecionado numa variavel | |
var PaisdoFinanciador = ListItem.get_item("Pa_x00ed_s"); | |
var clientContext = new SP.ClientContext.get_current(); | |
var PaisesList = clientContext.get_web().get_lists().getByTitle('Paises'); | |
// Query | |
var cmlQuery = new SP.CamlQuery(); | |
cmlQuery.set_viewXml('<View><Query><Where><Eq><FieldRef Name="Title" /><Value Type="Text">'+ PaisdoFinanciador + '</Value></Eq></Where></Query></View>'); | |
ListItem = PaisesList.getItems(cmlQuery); | |
clientContext.load(ListItem); | |
clientContext.executeQueryAsync(Function.createDelegate(this,this.SuccedPais), Function.createDelegate(this,this.Failed)); | |
} | |
function SuccedPais(sender, args){ | |
var ListItemEnumerator = ListItem.getEnumerator(); | |
while(ListItemEnumerator.moveNext()) | |
{ | |
//console.log(LItem.get_item('Title'), LItem.get_item('ID'), true, false)); | |
$('select[title="País do Financiadorr"]').empty(); | |
var LItem = ListItemEnumerator.get_current(); | |
$('select[title="País do Financiadorr"]').append(new Option(LItem.get_item('Title'), LItem.get_item('ID'), true, false)); | |
} | |
} | |
function Failed(sender, args) | |
{ | |
alert('Error. ' + args.get_message() + '\n' + args.get_stackTrace()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment