You need to sign in to do that
Don't have an account?
sObjects and object references ...
Hi guys,
I'm a C# developer so go easy on me.
I found this in the Data Loader source code ...
public void addReferenceToSObject(Controller controller, SObject sObj, String refFieldName) throws ParameterLoadException {
// break the name into relationship and field name components
ObjectField refField = new ObjectField(refFieldName);
String relationshipName = refField.getObjectName();
String fieldName = refField.getFieldName();
// get object info for the given reference (foreign key) relationship
DescribeRefObject entityRefInfo = controller.getReferenceDescribes().get(relationshipName);
// build the reference SObject
SObject sObjRef = new SObject();
// set entity type, has to be set before all others
sObjRef.setType(entityRefInfo.getObjectName());
// set external id, do type conversion as well
Class typeClass = SforceDynaBean.getConverterClass(entityRefInfo.getFieldInfoMap().get(fieldName));
Object extIdValue = ConvertUtils.convert(this.referenceExtIdValue.toString(), typeClass);
sObjRef.setField(fieldName, extIdValue);
// Add the sObject reference as a child elemetn, name set to relationshipName
sObj.addField(relationshipName, sObjRef);
}
I'm a little confused by the last line here, on the basis that the object passed in is "SObject sObj" from what I've seen in my type definition in C# this isn't possible.
Could someone explain what is going on here?
Is this an sObject or some other type?
If it is an sObject how do I do the equivelent of "sObj.addField" in C#?
Thanks guys.
Its an SObject. WSC (and many other java tools) allow you to use any object that it knows how to serialize as an element value, .NET which has a more pure XML only based API for its XmlElement class has no direct equivalent.