You need to sign in to do that
Don't have an account?
Cloud-Ling
HELP with trigger and XML
Greetings,
Now I have to create a trigger on Account that would parse the information(Name__c, Phone__c, Email__c, Address__c) in an XML format. I have to parse the information upon creating new record on Account and save the data to its appropriate fields on Contact object.
i.e. XML file --
<?xml version="1.0" ?> <!--My first XML document --> <information> <name> <first_name>Seed</first_name> <last_name>Lins</last_name> </name> <phone>888-8888-88</phone> <email>email@email.com</email> <address>Texas,USA</address> <name> <first_name>R</first_name> <last_name>Coholick</last_name> </name> <phone>662-546-54546</phone> <email>email@email.com</email> <address>Denver,USA</address> </information>
What am I gonna do?? I'm really confuse. Please help. Any ideas are welcome.
Thanks,
C-L
I have used XMLStreamReader class alot in past. This is what you'll want to use to parse your XML.
Salesforcealready has an example for what you want right here:
http://blog.sforce.com/sforce/2008/11/got-xml.html
Cory,
Thanks for the link, it was a big big help. Now I've created a class code and it didn't get errors so far, it look like this :
now, I've got to make a trigger that'll save/show the data to its appropriate fields on Contact. another question sir, how do I relate the Account to Contact?
All you need to do is populate the Contact.AccountID field with the ID of the Account. That will relate a Contact to an Acccount.
Once you have the Contact related to the Account, you don't need to use Trigger code to populate Account data on a Contact. You can use Custom Formula Fields to pull down Account values onto the Contact. You don't need to write trigger logic to do that piece.