Friday, November 11, 2011

Auto suggest box in cordys

var SEARCH_KEY = "";
---------------------------------------------------
application.importType("wcp.library.util.AutoSuggest");
application.importType("wcp.library.util.DataProvider");
application.addType(txtClientName, "wcp.library.util.AutoSuggest");
//Add required Autosuggest classes to the inputs
application.inherit(ClientsProvider, DataProvider)
txtClientName.registerDataProvider(new ClientsProvider());
-----------------------------------------------------------------

function ClientsProvider() {}
ClientsProvider.prototype.getSuggestions = function () {

var suggestions = null;
//read the current input vlaue if string length is less than 3 clear
var strValue = txtClientName.getValue();
if (strValue.length > 2 && SEARCH_KEY != strValue) {
//debugger;
// dont fire webservice again.. display the existing names' list if oldKey is the substr of newKey
if (strValue.toLowerCase().indexOf(SEARCH_KEY.toLowerCase()) != -1 && SEARCH_KEY != "") return NAME_LIST;
//empty the current name list and fill the new one
SEARCH_KEY = strValue;
suggestions = updateClientNameSuggestions(strValue);
NAME_LIST = suggestions;
}
return suggestions;
}
--------------------------------------
function Form_BeforeClose(eventObject) {
SEARCH_KEY = "";
}

Saturday, November 5, 2011

getCordysUserName

function getCordysUserName()
{
var usrname;
var stindex;
var endindex;
usrname = system.getUser().organizations[application.organization].userDN;
stindex = usrname.indexOf(",",0);
strlength = stindex-3;
gUser = usrname;
return usrname.substr(3,strlength);
}