+ Start a Discussion
BAGELBAGEL 

Urgent, please help.

Hi everyone,

I am using 7.0 api and 3.3 ajax toolkit. I have 2 custom objects. Everything works just fine. Until I repackage my app with the new manage package feature. I understand that I will need to modified my code to add the new prefix to each instance of custom objects and custom fields.

I can successfully get the data from one of my object. However, the other object I have problem with. Even as simple as I retrieve the Id field of the object, I still get a script error in the sforceclient.js saying

db.getItem(key) has no properties
var v = db.getItem(key).value;

Anyone has any clues?

Thanks in advance.


Ron HessRon Hess
send more code?

i can't see any problem with that line :smileyhappy:
BAGELBAGEL
when I try to call this, it gives me error.
 
 sforceClient.Query("Select CreatedById, CreatedDate, Id, LastModifiedById, LastModifiedDate, Name, OwnerId, Stage_Override__c, Importances_List__c, WL_Reasons_List__c, Barriers_List__c, SystemModstamp from WAYS_SCMgr_Config__c", hConfig, true);
all the fields are defined in the custom object.
 
even when I just query Id, it still gives me an error.
 
However, when I query a different cutom object, it returns recordset just fine.
 
Thanks again.
 
Ron HessRon Hess
looks ok, can you get the error message from the Query() , this will be returned or passed into the hConfig function. 

if it is providing an error but your code does not check for error, then you may see a property error as you describe, but that is a secondary error.

The real error will be passed back in a SOAP message which the toolkit will then send to your function.

can you include a bit more code?  need to see what is going on between this query and the error you see.

the hConfig() function will probably have the check for success / error that is what we need to see next.
BAGELBAGEL
here is the hConfig function, but the error occurs before it reached here.
 
function hConfig(qr){
 var DEBUG = true;
 if(DEBUG)alert(qr.toString());
    if (qr.className != "QueryResult"){
        alert(qr.className + " object not available. " +
            qr.toString());
        return ;
    }
 if (qr.size == 0)
  return false;
 if (qr.size > 0){
  var oConfig = qr.records[0];
  StageOverride = oConfig.get("WAYS__Stage_Override__c");
  tmpImpList = oConfig.get("WAYS__Importances_List__c");
  tmpReaList = oConfig.get("WL_Reasons_List__c");
  tmpBarList = oConfig.get("WAYS__Barriers_List__c");
  findAdvisorRecord(id);
 }
}
 
And here is the rest of the function that makes the query..
 
function pageInit(){
 var debug = false;
 
 sforceClient.init("{!API_Session_ID}", "{!API_Partner_Server_URL_70}");
 if (sforceClient.getSessionId().indexOf("!API_Session_ID") != - 1){
  alert("Could not login using API");
  return ;
 }
 var uInfo = sforceClient.GetUserInfo(); // has the locale
 userLocale = uInfo.userLocale;
 dformat = Sforce.Util.GetLocaleDateFormat(uInfo.userLocale);
 if (uInfo && uInfo.faultcode && uInfo.faultcode.indexOf("API_DISABLED_FOR_ORG") > 0) 
 {
  alert(uInfo.faultstring +
   "\nThis custom link utilizes the AppExchange API.\n" +
   "It appears that the Salesforce.com edition you are using does not have this feature enabled.");
  return ;
 }

 sforceClient.Query("Select CreatedById, CreatedDate, Id, LastModifiedById, LastModifiedDate, Name, OwnerId, Stage_Override__c, Importances_List__c, WL_Reasons_List__c, Barriers_List__c, SystemModstamp from WAYS_SCMgr_Config__c", hConfig, true);

}
Ron HessRon Hess
looks like it should work, don't know why it fails when running in your org.

new AJAX toolkit is better suited to scontrol development and supported, this beta3.3 version had a minor bug in the getuserinfo(), you may be hitting that.
you could try to comment out all the getuserinfo stuff, but it's quick to port this to the latest AJAX, performance is better also.
BAGELBAGEL
Interestingly, if I query w/o callback function, it does not give me error.

sforceClient.Query("Select CreatedById, CreatedDate, Id, LastModifiedById, LastModifiedDate, Name, OwnerId, WAYS__Stage_Override__c, WAYS__Importances_List__c, WAYS__WL_Reasons_List__c, WAYS__Barriers_List__c, SystemModstamp from WAYS__WAYS_SCMgr_Config__c");


BAGELBAGEL
When I use FireBug to look at the error, I see this.

db.getItem(key) has no properties

toString(" ")
hConfig( className=QueryResult records=[1] size=1 done=true)
internalCallback(XMLHttpRequest readState=4)
internalCallBack(2)
f()

var v = db.getItem(key).value;

BAGELBAGEL
Hm... apparently this line give me the problem in the callback function.

qr.toString()
Ron HessRon Hess
i guess you should check for null before calling .toString()

but that's probably not the root of the problem, just a guess