You need to sign in to do that
Don't have an account?

Can upserts with external id foreign keys be done using the Partner WSDL?
I'm trying to figure out how to do an upsert to an object setting it's parent using a foreign key to it's parent's external ID using the partner WSDL. The example in the 8.0 docs only shows this being done using the enterprise WSDL, is this possible?
Can you please provide a snippet of code (preferably c#) showing how this is done?
Thanks
An 8.0 Sample can be found here.
https://wiki.apexdevnet.com/index.php/API#Java
Here is your example from your API docs (page 168) of what I am trying to do using using the partner WSDL, but it uses the enterprise WSDL:
You can use external ID fields as a foreign key, allowing you to access records in a single step instead of querying a record to get the ID first.To do this, specify the foreign key name and the external ID field value. For example:
Opportunity upsertOpportunity = new Opportunity();
upsertOpportunity.setStageName("Prospecting");
// Standard object ref
Account upsertParentAccountRef = new Account();
upsertParentAccountRef.setExternal_SAP1_ACCTID__c("SAP111111");
upsertOpportunity.setAccount(upsertParentAccount);
// Opportunity ref
upsertOpportunity.set_SAP1_OPPID__c("SAP222222");
UpsertResult[] upsertResults = binding.upsert("SAP1_OPPID__c",
new SObject[] {upsertOpportunity});
SimonF said it could be done, but I needed to "manually build the nested element structure". I'm looking for an example of how this is done.
Thanks.
sf.SforceService s = new sf.SforceService();
login(s);
XmlDocument doc = new XmlDocument();
sf.sObject contact = new sf.sObject();
contact.type = "Contact";
XmlElement lastName = Element(doc, "LastName", "Flintstone");
XmlElement firstName = Element(doc, "FirstName", "Fred");
XmlElement contactExt = Element(doc, "Ext__c", "123123321");
XmlElement account = Element(doc, "Account", null);
account.AppendChild(Element(doc, "type", "Account"));
account.AppendChild(Element(doc, "SystemId__c", "BEDROCK_01"));
contact.Any = new XmlElement[] { contactExt, lastName, firstName, account} ;
sf.UpsertResult sr = s.upsert("Ext__c", new sf.sObject[] { contact })[0];
if (sr.success)
Console.WriteLine("Success! id of contact is {0}", sr.id);
else
Console.WriteLine("{0} {1}", sr.errors[0].statusCode, sr.errors[0].message);
}
static XmlElement Element(XmlDocument doc, String name, String val)
{
XmlElement e = doc.CreateElement(name);
if (val != null) e.InnerText = val;
return e;
}
Can this be done with the Enterprise WSDL using C# ?
I don't see a way of calling this line: upsertOpportunity.setAccount(upsertParentAccount);
In fact, it doesn't look like this variable (upsertParentAccount) is declared in the java example, so I don't see how this even compiles.
I only get the option to set the AccountId in C#, so how do I set the parent account to take advantage of the single step access?
Carlos
You can use external ID fields as a foreign key, allowing you to access records in a single step instead of querying a record to get the ID first.To do this, specify the foreign key name and the external ID field value. For example:
Opportunity upsertOpportunity = new Opportunity();
upsertOpportunity.setStageName("Prospecting");
// Standard object ref
Account upsertParentAccountRef = new Account();
upsertParentAccountRef.setExternal_SAP1_ACCTID__c("SAP111111");
upsertOpportunity.setAccount(upsertParentAccount);
// Opportunity ref
upsertOpportunity.set_SAP1_OPPID__c("SAP222222");
UpsertResult[] upsertResults = binding.upsert("SAP1_OPPID__c",
new SObject[] {upsertOpportunity});
Hi,
Can this whole process be done from the Apex code rather than javascript or C#.In C# we are adding a web reference.In javascript again we have the connection to WSDL.But how to go about if we want to implement it through Apex code.Say reset Password in User Object.If we are going for javascript then it is not at all secure.
Please help.
Regards
Hi,
That was just an example.
Actually I want to change the password of a specific User.How to go about it?
If you can provide some sample that would be of great help.
Thanks in Advance....
Hi Simon,
I am stuck at this point.Please help.
For security reasons, you cannot query User passwords via the API or the Salesforce user interface. However, the API allows
you to set and “reset” User passwords using the setPassword and resetPassword calls.
Requirement is to add a new user to Salesforce (not using Salesforce UI) through code.
Adding a user to Salesforce is followed by the setPassword call.We dont have any idea where exactly the password of the Users are saved.Please provide some pointers on how to set the Password of User.
Regards,
Should I go for javascript to set the password by calling
sforce.connection.setPassword(id, password);
What about the security of password if i use javascript?
Regards.