You need to sign in to do that
Don't have an account?
saariko.ax241
Advanced: updating a class member with out knowing it's name
I have an xml I get from an external program. this XML holds information about multiple, unknown fields and their values. the fields are a subset of a custom object in SF.
My question:
How can I set the value I get from the XML in the SF object?
Limitations:
I dont' want to use a long if else/switch list
I don't want to update the code when in the future I add new fields to the SF object (the XML program will know of the new fields - and update them if needed)
XML example:
*The attribute : SF_Module_Name - holds the name of the SF Object member I want to set to true.
Code:
I couldn't really figure how to use reflection on my object, since I couldnt' see how it is hashable, nor is it a mapped table.
<—xml version="1.0" encoding="iso-8859-1"–> <sale> <trxdata> <action>new</action> </trxdata> <Plugs> <Plug> <Dongle_ID__c>1576718528</Dongle_ID__c> <License_Expiration_Date> </License_Expiration_Date> </Plug> </Plugs> <Modules> <Module> <Dongle_ID__c></Dongle_ID__c> <Id> </Id> <Module_Name>OptiMark</Module_Name> <Module_Version>900</Module_Version> <SF_Module_Name>X1</SF_Module_Name> </Module> <Module> <Dongle_ID__c></Dongle_ID__c> <Id> </Id> <Module_Name>Optikk</Module_Name> <Module_Version>900</Module_Version> <SF_Module_Name>X2</SF_Module_Name> </Module> <Module> <Dongle_ID__c></Dongle_ID__c> <Id> </Id> <Module_Name>Opti33</Module_Name> <Module_Version>900</Module_Version> <SF_Module_Name>X3</SF_Module_Name> </Module> </Modules> </sale>
I couldn't really figure how to use reflection on my object, since I couldnt' see how it is hashable, nor is it a mapped table.
Does anyone have an idea?
I tried to play with the code in http://community.salesforce.com/sforce/board/message?board.id=NET_development&message.id=3733#M3733 but couldnt make it work.
Thanks Simon, indeed, the partner WSDL was what I was looking for.
just for reference, my code now looks like this:
Code: