function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Keaton KleinKeaton Klein 

sobject type 'Trust_Contact__C' not supported

I have written some code which adds records to an object.  In case case i am trying to add a record to a custom object.  When running this code i get an error message stating that the sObject type 'Trust_Contact__C' is not supported.  As a test a created a new custom object 'Test_Object__C" and ran the same exact code but changed the type to 'Test_Object__C' and i commented out the a few of the fields (second code sample).  What really confuses me is that it worked with the Test Object and not with the Trust Contact object.  I also inserted screenshots from each object in Salesforce.  Any ideas?
 
cmd.CommandText = "SELECT  top(10)   dbo.keat_crossreference.* FROM  dbo.keat_crossreference";
                cmd.CommandType = CommandType.Text;
                cmd.Connection = sqlConnection1;

                sqlConnection1.Open();

                reader = cmd.ExecuteReader();
                var nexty = reader;
                // Data is accessible through the DataReader object here.
                int ir = 0;
                sObject[] cons = new sObject[1];
                apex.sObject contact;
                var pretrust ="pre";
                var buildid = "";
                var pair = "";
                var crdesc = "";
                var acctno = "";
                var naidno = "";
                while (reader.Read())
                {
                    if (reader.GetValue(reader.GetOrdinal("account_no")).ToString()==pretrust)
                    {
                         
                         buildid = buildid +','+ reader.GetValue(reader.GetOrdinal("buildid")).ToString();
                         pair = pair + ',' + reader.GetValue(reader.GetOrdinal("pair")).ToString();
                         crdesc = crdesc + ',' + reader.GetValue(reader.GetOrdinal("cross_ref_type_cd_dsc")).ToString();
                         acctno = acctno + ',' + reader.GetValue(reader.GetOrdinal("account_no")).ToString();
                         naidno = naidno + ',' + reader.GetValue(reader.GetOrdinal("name_addr_id")).ToString();
                         pretrust = reader.GetValue(reader.GetOrdinal("account_no")).ToString();
                        ir++;
                    }
                    else
                    {
                    ir++;
                    pretrust = reader.GetValue(reader.GetOrdinal("account_no")).ToString();
                    //Verify that we are already authenticated, if not
                    //call the login function to do so
                    if (!loggedIn)
                    {
                        if (!login())
                            return;
                    }

                    try
                    {

                        for (int j = 0; j < cons.Length; j++)
                        {
                            contact = new apex.sObject();
                            int index = 0;
                            System.Xml.XmlElement[] cont = new System.Xml.XmlElement[17];
                            if (accounts != null)
                            {
                                cont = new System.Xml.XmlElement[cont.Length + 1];
                                cont[index++] = GetNewXmlElement("AccountId", accounts[0]);
                            }

                            cont[index++] = GetNewXmlElement("contact__C", naidno);
                            cont[index++] = GetNewXmlElement("Relationship_Type__c", crdesc);
                            //cont[index++] = GetNewXmlElement("Role__c", addy1);
                            cont[index++] = GetNewXmlElement("Trust__c", acctno);
                            contact.Any = cont;
                            contact.type = "Trust_Contact__C";
                            cons[j] = contact;
                        }
                        SaveResult[] sr = binding.create(cons);

//cont[index++] = GetNewXmlElement("contact__C", naidno);
                            //cont[index++] = GetNewXmlElement("Relationship_Type__c", crdesc);
                            //cont[index++] = GetNewXmlElement("Role__c", addy1);
                            cont[index++] = GetNewXmlElement("name", acctno);
                            contact.Any = cont;
                            contact.type = "Test_Object__c";
                            cons[j] = contact;

Test ObjectTrust Contact
Best Answer chosen by Keaton Klein
Keaton KleinKeaton Klein
It turns out the solutions was to update the API version.  I was using version 10 which does not recognize junction objects.  Upgrading to 30 solved my issue.

All Answers

kevin lamkevin lam
Have you tried "Trust_Contact__c"?
Keaton KleinKeaton Klein
Thanks for the suggestion Kevin.  I did confirm and retry "Trust_Contact__c" and continue to get the "Not Supported" error message.
for (int j = 0; j < cons.Length; j++)
                        {
                            contact = new apex.sObject();
                            int index = 0;
                            System.Xml.XmlElement[] cont = new System.Xml.XmlElement[17];
                            if (accounts != null)
                            {
                                cont = new System.Xml.XmlElement[cont.Length + 1];
                                cont[index++] = GetNewXmlElement("AccountId", accounts[0]);
                            }

                            cont[index++] = GetNewXmlElement("contact__C", naidno);
                            cont[index++] = GetNewXmlElement("Relationship_Type__c", crdesc);
                            //cont[index++] = GetNewXmlElement("Role__c", addy1);
                            cont[index++] = GetNewXmlElement("name", acctno);
                            contact.Any = cont;
                            contact.type = "Trust_Contact__c";
                            cons[j] = contact;
                        }
                        SaveResult[] sr = binding.create(cons);

 
Keaton KleinKeaton Klein
It turns out the solutions was to update the API version.  I was using version 10 which does not recognize junction objects.  Upgrading to 30 solved my issue.
This was selected as the best answer