• Jim Zhan
  • NEWBIE
  • 0 Points
  • Member since 2006

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 7
    Replies
I'm using ZSI ver2.0 to access Salesforce with partner.wsdl.xml, I can now use login/query/describe methods, but how can I create a Sobject to construct the creation request? I really have no idea about it. Here's the definition of Sobject & Create from the file I generated by using wsdl2py (with params: wsdl2py -ebf partner.wsdl.xml)

Code:
class sObject_Def(ZSI.TCcompound.ComplexType, TypeDefinition):
    schema = "urn:sobject.partner.soap.sforce.com"
    type = (schema, "sObject")
    def __init__(self, pname, ofwhat=(), attributes=None, extend=False, restrict=False, **kw):
        ns = ns0.sObject_Def.schema
        TClist = [ZSI.TC.String(pname=(ns,"type"), aname="_type", minOccurs=1, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), ZSI.TC.String(pname=(ns,"fieldsToNull"), aname="_fieldsToNull", minOccurs=0, maxOccurs="unbounded", nillable=True, typed=False, encoded=kw.get("encoded")), GTD("urn:partner.soap.sforce.com","ID",lazy=False)(pname=(ns,"Id"), aname="_Id", minOccurs=1, maxOccurs=1, nillable=True, typed=False, encoded=kw.get("encoded")), ZSI.TC.AnyElement(aname="_any", minOccurs=0, maxOccurs="unbounded", nillable=False, processContents="lax")]
        self.attribute_typecode_dict = attributes or {}
        if extend: TClist += ofwhat
        if restrict: TClist = ofwhat
        ZSI.TCcompound.ComplexType.__init__(self, None, TClist, pname=pname, inorder=0, **kw)
        class Holder:
            __metaclass__ = pyclass_type
            typecode = self
            def __init__(self):
                # pyclass
                self._type = None
                self._fieldsToNull = []
                self._Id = None
                self._any = []
                return
        Holder.__name__ = "sObject_Holder"
        self.pyclass = Holder

 Code:
class create_Dec(ZSI.TCcompound.ComplexType, ElementDeclaration):
    literal = "create"
    schema = "urn:partner.soap.sforce.com"
    def __init__(self, **kw):
        ns = ns1.create_Dec.schema
        TClist = [GTD("urn:sobject.partner.soap.sforce.com","sObject",lazy=False)(pname=(ns,"sObjects"), aname="_sObjects", minOccurs=0, maxOccurs="unbounded", nillable=False, typed=False, encoded=kw.get("encoded"))]
        kw["pname"] = ("urn:partner.soap.sforce.com","create")
        kw["aname"] = "_create"
        self.attribute_typecode_dict = {}
        ZSI.TCcompound.ComplexType.__init__(self,None,TClist,inorder=0,**kw)
        class Holder:
            __metaclass__ = pyclass_type
            typecode = self
            def __init__(self):
                # pyclass
                self._sObjects = []
                return
        Holder.__name__ = "create_Holder"
        self.pyclass = Holder

class createResponse_Dec(ZSI.TCcompound.ComplexType, ElementDeclaration):
    literal = "createResponse"
    schema = "urn:partner.soap.sforce.com"
    def __init__(self, **kw):
        ns = ns1.createResponse_Dec.schema
        TClist = [GTD("urn:partner.soap.sforce.com","SaveResult",lazy=False)(pname=(ns,"result"), aname="_result", minOccurs=0, maxOccurs="unbounded", nillable=False, typed=False, encoded=kw.get("encoded"))]
        kw["pname"] = ("urn:partner.soap.sforce.com","createResponse")
        kw["aname"] = "_createResponse"
        self.attribute_typecode_dict = {}
        ZSI.TCcompound.ComplexType.__init__(self,None,TClist,inorder=0,**kw)
        class Holder:
            __metaclass__ = pyclass_type
            typecode = self
            def __init__(self):
                # pyclass
                self._result = []
                return
        Holder.__name__ = "createResponse_Holder"
        self.pyclass = Holder 
any help will be appreciated.
 


Ruby 1.8.5-p12
Rails 1.2.2
ActiveSalesforce 1.1.0

# environment.rb
Rails::Initializer.run do |config|   
    # Add Salesforce support into ActiveRecord
    require_gem 'activesalesforce' 
end

# database.yaml
adapter: activesalesforce
url: https://test.salesforce.com
username: <username>
password: <password>


Then I got these errors:

Code:
=> Booting WEBrick...
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/dependencies.rb:263:in `load_missing_constant': uninitialized constant ActiveRecord::ConnectionAdapters::Column (NameError)
        from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/dependencies.rb:452:in `const_missing'
        from c:/ruby/lib/ruby/gems/1.8/gems/activesalesforce-1.1.0/lib/column_definition.rb:32
        from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
        from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
        from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/dependencies.rb:495:in `require'
        from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/dependencies.rb:342:in `new_constants_in'
        from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/dependencies.rb:495:in `require'
        from c:/ruby/lib/ruby/gems/1.8/gems/activesalesforce-1.1.0/lib/asf_adapter.rb:25
         ... 30 levels...
        from c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.2/lib/commands/server.rb:39
        from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
        from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
        from server:3


 

Can I make custom button conditionally appear on a detail page? If yes, how can I do that? Otherwise, any tricky way to do so?
My S-Control works fine on IE and Firefox, but stuck on Opera with the following error:

===========================================================
[Error: name: TypeError message: Statement on line 925: Could not convert undefined or null to object Backtrace: Line 925 of linked script https://emea.salesforce.com/soap/ajax/8.0/connection.js var ns = node.nodeName.split(":"); Line 890 of linked script https://emea.salesforce.com/soap/ajax/8.0/connection.js if (this.isTag("Envelope", this.envelope)) Line 1134 of linked script https://emea.salesforce.com/soap/ajax/8.0/connection.js var envelope2 = reader2.getEnvelope(); Line 715 of linked script https://emea.salesforce.com/soap/ajax/8.0/connection.js holder.callback.httpCallback("Remote invocation failed, due to: " + holder.connection.responseText + " status code: ", holder.connection.status); Line 697 of linked script https://emea.salesforce.com/soap/ajax/8.0/connection.js this.httpConnectionCallback(); Line 1081 of linked script https://emea.salesforce.com/soap/ajax/8.0/connection.js transport.send(writer.toString(), this, this.isAsync); Line 1589 of linked script https://emea.salesforce.com/soap/ajax/8.0/connection.js return transport.send(url, writer, isArray, callback); Line 1532 of linked script https://emea.salesforce.com/soap/ajax/8.0/connection.js return this._invoke(method, args, isArray, callback, this.namespaceMap, this.serverUrl, this.sforceNs, this.sobjectNs); Line 1267 of linked script https://emea.salesforce.com/soap/ajax/8.0/connection.js return this.invoke("create", [arg], true, callback); Line 467 of inline#3 script in https://emea.salesforce.com/servlet/servlet.Integration?lid=01N2000000008Iv⁣=1&contactId=00320000006P63S&productId=a0U200000008YGh&productInterestId=a0S200000008QL6 var result = sforce.connection.create([opportunity]); Line 303 of inline#3 script in https://emea.salesforce.com/servlet/servlet.Integration?lid=01N2000000008Iv⁣=1&contactId=00320000006P63S&productId=a0U200000008YGh&productInterestId=a0S200000008QL6 createOpportunity(opportunity); Line 1126 of linked script https://emea.salesforce.com/soap/ajax/8.0/connection.js this.connectionCallback.onSuccess(this.result, this.connectionCallback.source); Line 712 of linked script https://emea.salesforce.com/soap/ajax/8.0/connection.js holder.callback.httpCallback(holder.connection.responseXML.documentElement, success); At unknown location [statement source code not available] ]
[/code]
I have a S-control which is still using AJAX 7.0, a regular query & update function puzzlingly kick me out of Salesforce, but I can see the data is already updated after I re-login to the page, and the same function works well in another simple S-control.
Code:
<html>
<script src="/soap/ajax/8.0/connection.js"></script>
<script type="text/javascript">
function setup() {
 var callback = {onSuccess: display, onFailure: failed};
 var userInfo = sforce.connection.getUserInfo(callback);
}

function display(userInfo) {
 var doc = document.getElementById("name-span");
 doc.innerHTML = userInfo.userName;
}

function failed(error) {
 document.getElementById("name-span").innerHTML = error.toString();
}
</script>

<body onload="setup()">
 Hi there! <span id="name-span"></span>
</body>

</html>

 


I then got such an error:
Code:
An error has occurred: {faultcode:'sf:INVALID_SESSION_ID', faultstring:'INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session', detail:{fault:{exceptionCode:'INVALID_SESSION_ID', exceptionMessage:'Invalid Session ID found in SessionHeader: Illegal Session', }, }, }

Any help will be appreciated, thanks in advance & happy new year to all.

I'm using ZSI ver2.0 to access Salesforce with partner.wsdl.xml, I can now use login/query/describe methods, but how can I create a Sobject to construct the creation request? I really have no idea about it. Here's the definition of Sobject & Create from the file I generated by using wsdl2py (with params: wsdl2py -ebf partner.wsdl.xml)

Code:
class sObject_Def(ZSI.TCcompound.ComplexType, TypeDefinition):
    schema = "urn:sobject.partner.soap.sforce.com"
    type = (schema, "sObject")
    def __init__(self, pname, ofwhat=(), attributes=None, extend=False, restrict=False, **kw):
        ns = ns0.sObject_Def.schema
        TClist = [ZSI.TC.String(pname=(ns,"type"), aname="_type", minOccurs=1, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), ZSI.TC.String(pname=(ns,"fieldsToNull"), aname="_fieldsToNull", minOccurs=0, maxOccurs="unbounded", nillable=True, typed=False, encoded=kw.get("encoded")), GTD("urn:partner.soap.sforce.com","ID",lazy=False)(pname=(ns,"Id"), aname="_Id", minOccurs=1, maxOccurs=1, nillable=True, typed=False, encoded=kw.get("encoded")), ZSI.TC.AnyElement(aname="_any", minOccurs=0, maxOccurs="unbounded", nillable=False, processContents="lax")]
        self.attribute_typecode_dict = attributes or {}
        if extend: TClist += ofwhat
        if restrict: TClist = ofwhat
        ZSI.TCcompound.ComplexType.__init__(self, None, TClist, pname=pname, inorder=0, **kw)
        class Holder:
            __metaclass__ = pyclass_type
            typecode = self
            def __init__(self):
                # pyclass
                self._type = None
                self._fieldsToNull = []
                self._Id = None
                self._any = []
                return
        Holder.__name__ = "sObject_Holder"
        self.pyclass = Holder

 Code:
class create_Dec(ZSI.TCcompound.ComplexType, ElementDeclaration):
    literal = "create"
    schema = "urn:partner.soap.sforce.com"
    def __init__(self, **kw):
        ns = ns1.create_Dec.schema
        TClist = [GTD("urn:sobject.partner.soap.sforce.com","sObject",lazy=False)(pname=(ns,"sObjects"), aname="_sObjects", minOccurs=0, maxOccurs="unbounded", nillable=False, typed=False, encoded=kw.get("encoded"))]
        kw["pname"] = ("urn:partner.soap.sforce.com","create")
        kw["aname"] = "_create"
        self.attribute_typecode_dict = {}
        ZSI.TCcompound.ComplexType.__init__(self,None,TClist,inorder=0,**kw)
        class Holder:
            __metaclass__ = pyclass_type
            typecode = self
            def __init__(self):
                # pyclass
                self._sObjects = []
                return
        Holder.__name__ = "create_Holder"
        self.pyclass = Holder

class createResponse_Dec(ZSI.TCcompound.ComplexType, ElementDeclaration):
    literal = "createResponse"
    schema = "urn:partner.soap.sforce.com"
    def __init__(self, **kw):
        ns = ns1.createResponse_Dec.schema
        TClist = [GTD("urn:partner.soap.sforce.com","SaveResult",lazy=False)(pname=(ns,"result"), aname="_result", minOccurs=0, maxOccurs="unbounded", nillable=False, typed=False, encoded=kw.get("encoded"))]
        kw["pname"] = ("urn:partner.soap.sforce.com","createResponse")
        kw["aname"] = "_createResponse"
        self.attribute_typecode_dict = {}
        ZSI.TCcompound.ComplexType.__init__(self,None,TClist,inorder=0,**kw)
        class Holder:
            __metaclass__ = pyclass_type
            typecode = self
            def __init__(self):
                # pyclass
                self._result = []
                return
        Holder.__name__ = "createResponse_Holder"
        self.pyclass = Holder 
any help will be appreciated.
 


Ruby 1.8.5-p12
Rails 1.2.2
ActiveSalesforce 1.1.0

# environment.rb
Rails::Initializer.run do |config|   
    # Add Salesforce support into ActiveRecord
    require_gem 'activesalesforce' 
end

# database.yaml
adapter: activesalesforce
url: https://test.salesforce.com
username: <username>
password: <password>


Then I got these errors:

Code:
=> Booting WEBrick...
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/dependencies.rb:263:in `load_missing_constant': uninitialized constant ActiveRecord::ConnectionAdapters::Column (NameError)
        from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/dependencies.rb:452:in `const_missing'
        from c:/ruby/lib/ruby/gems/1.8/gems/activesalesforce-1.1.0/lib/column_definition.rb:32
        from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
        from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
        from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/dependencies.rb:495:in `require'
        from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/dependencies.rb:342:in `new_constants_in'
        from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/dependencies.rb:495:in `require'
        from c:/ruby/lib/ruby/gems/1.8/gems/activesalesforce-1.1.0/lib/asf_adapter.rb:25
         ... 30 levels...
        from c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.2/lib/commands/server.rb:39
        from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
        from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
        from server:3


 

I have a S-control which is still using AJAX 7.0, a regular query & update function puzzlingly kick me out of Salesforce, but I can see the data is already updated after I re-login to the page, and the same function works well in another simple S-control.
Code:
<html>
<script src="/soap/ajax/8.0/connection.js"></script>
<script type="text/javascript">
function setup() {
 var callback = {onSuccess: display, onFailure: failed};
 var userInfo = sforce.connection.getUserInfo(callback);
}

function display(userInfo) {
 var doc = document.getElementById("name-span");
 doc.innerHTML = userInfo.userName;
}

function failed(error) {
 document.getElementById("name-span").innerHTML = error.toString();
}
</script>

<body onload="setup()">
 Hi there! <span id="name-span"></span>
</body>

</html>

 


I then got such an error:
Code:
An error has occurred: {faultcode:'sf:INVALID_SESSION_ID', faultstring:'INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session', detail:{fault:{exceptionCode:'INVALID_SESSION_ID', exceptionMessage:'Invalid Session ID found in SessionHeader: Illegal Session', }, }, }

Any help will be appreciated, thanks in advance & happy new year to all.