I'm having an issue with my variable. I'm not sure if it is syntax related, but for some reason the first part of my if
statement with my variable will not work.
I tested it without the SPServices
and if I just do that function without SPServices
it works. I also tested SPServices
with alerts and not the variable, and those work fine too. Please see code below, any help is appreciated. Thanks!
$(document).ready(function(){
var dropdown = $("select[title='Item-Status']");
$().SPServices({
operation: "GetGroupCollectionFromUser",
userLoginName: $().SPServices.SPGetCurrentUser(),
async: false,
completefunc: function(xData, Status) {
if ($(xData.responseXML).find("Group[Name='CCB Team']").length == 0) {
dropdown.find("option[value='QA Review']").remove();
} else if ($(xData.responseXML).find("Group[Name='QA Team']").length == 1) {
alert("You should see this");
}
}
});
});
never mind. i realized i was declaring the variable outside of the function i wanted to use it under. code should be written as so:
$(document).ready(function(){
$().SPServices({
operation: "GetGroupCollectionFromUser",
userLoginName: $().SPServices.SPGetCurrentUser(),
async: false,
completefunc: function(xData, Status) {
var dropdown = $("select[title='Item-Status']");
if ($(xData.responseXML).find("Group[Name='CCB Team']").length == 0) {
dropdown.find("option[value='QA Review']").remove();
} else if ($(xData.responseXML).find("Group[Name='QA Team']").length == 1) {
alert("You should see this");
}
}
});
});