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

Just a litle code that can help you !?
Hi,
For my personnel needs I have done generic "update" and "delete" functions.
Code:
For my personnel needs I have done generic "update" and "delete" functions.
Code:
public string Create(string type, Hashtable fields)
{
try
{
Assembly A = Assembly.GetExecutingAssembly();
Type[] Ts = A.GetExportedTypes();
Type T = null;
// Type
object ob = null;
foreach (Type t in Ts)
if (t.Name == type)
{
T = t;
break;
}
if (T == null)
return null;
// Object
ob = Activator.CreateInstance(T);
IDictionaryEnumerator Enum = fields.GetEnumerator();
while (Enum.MoveNext())
if (T.GetField(Enum.Key.ToString()) != null && Enum.Value != null)
{
FieldInfo info = T.GetField(Enum.Key.ToString());
info.SetValue(ob, Enum.Value);
}
SaveResult[] Result = S.create(new sObject[]{(sObject)ob});
if (Result[0].success == true)
return Result[0].id;
else {return null;}
}
catch (Exception ex){return null;}
I hope it will help you !
Just past the type of the object to create (ex: "Lead") and a HashTable
wish associates FieldName and Value (ex: "City" / "New York");
It manage fieldsToNull
Please tell me what you think about it !
Have you tried using the partner API, that's pretty generic and doesn't need all the reflection stuff.

Is it available to any organization ? or we must be a SalesForce Partner ?
Anyone who can use the enterprise API can also use the partner API.

Thank you I will try this !!!