• Sam961
  • NEWBIE
  • 25 Points
  • Member since 2012

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 5
    Replies

Im trying to return the text of multiple xml elements with the same name. Im using Xmlnode.

 

Heres part of the code that handles the response:

 

// Get xml body from response
dom.Document docx = res.getBodyDocument();
dom.Xmlnode xroot = docx.getRootElement();
dom.Xmlnode xrec = xroot.getChildElement('error', null);

// Setup email for exception
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();            
String[] toAddress = new String[] {ownerEmail};
mail.setToAddresses(toAddress);
mail.setSenderDisplayName('Salesforce');
mail.setSubject('A problem has occured with creating the Proposal');
mail.setPlainTextBody('The following error occured when trying to create the Proposal: \n\n"Proposal ' + newError + '"\n\nPlease correct the errors above and try again.');    
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

 

The reponse would look something like:

 

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<errors>
    <error>advertiser can't be blank</error>
    <error>name can't be blank</error>
    <error>campaign_type can't be blank</error>
    <error>start_date can't be blank</error>
</errors>

 

Right now it only returns the text from the first "error" element.

 

Ive looked at the xmlnode docs, but Im having a hard time understanding how to get the text from all of the nodes.

 

Any help would be much appreciated!!


Thanks!

  • August 15, 2012
  • Like
  • 0

helloo

 

how much should be Trigger Code Coverage  in order to deploy to production or to do a package ?

 

thanks in advance

 

sam

 

 

  • October 05, 2012
  • Like
  • 0

helooo

 

 may i know , how to add invitee in a perticular event through apex Programing.

 

i have been trying ths since from long time ,, some says ter is no option of adding invitees through programing ...

 

can any one tell me wether can i doo it or not ?

if we can, please suggest me the way ?

if not ,  y ?

 

thanks in advance

 

regards

 

sam961 

  • August 18, 2012
  • Like
  • 0

helooo 

i want to acesses IMAP server in salesforce but i m unable to do it .. i m not having any idea how to write in Apex Down hear i m writing the code in java . in the same manner i want t o write in Apex . please can any one guide me how to write in Apex. ???

ex;- i dint found any session class,properties class, or methods in apex , can u  guide me please ...

 

thanks  in advance

sam

 

 

import java.util.Properties;

import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.NoSuchProviderException;
import javax.mail.Session;
import javax.mail.Store;

public class InboxReader {

public static void main(String args[]) {
Properties props = System.getProperties();
props.setProperty("mail.store.protocol", "imaps");
try {
Session session = Session.getDefaultInstance(props, null);
Store store = session.getStore("imaps");
store.connect("imap.gmail.com", "<username>", "password");
System.out.println(store);

Folder inbox = store.getFolder("Inbox");
inbox.open(Folder.READ_ONLY);
Message messages[] = inbox.getMessages();
for(Message message:messages) {
System.out.println(message);
}
} catch (NoSuchProviderException e) {
e.printStackTrace();
System.exit(1);
} catch (MessagingException e) {
e.printStackTrace();
System.exit(2);
}

}

}

  • August 16, 2012
  • Like
  • 0

Hi 

I have a doubt,Please help me out...

I have created one custom object and added it to some appications..if i want to know how many appications having visibilty off this object,what should i do....

Thanks in advance....

 

 

  • August 10, 2012
  • Like
  • 0

helooo 

i want to acesses IMAP server in salesforce but i m unable to do it .. i m not having any idea how to write in Apex Down hear i m writing the code in java . in the same manner i want t o write in Apex . please can any one guide me how to write in Apex. ???

ex;- i dint found any session class,properties class, or methods in apex , can u  guide me please ...

 

thanks  in advance

sam

 

 

import java.util.Properties;

import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.NoSuchProviderException;
import javax.mail.Session;
import javax.mail.Store;

public class InboxReader {

public static void main(String args[]) {
Properties props = System.getProperties();
props.setProperty("mail.store.protocol", "imaps");
try {
Session session = Session.getDefaultInstance(props, null);
Store store = session.getStore("imaps");
store.connect("imap.gmail.com", "<username>", "password");
System.out.println(store);

Folder inbox = store.getFolder("Inbox");
inbox.open(Folder.READ_ONLY);
Message messages[] = inbox.getMessages();
for(Message message:messages) {
System.out.println(message);
}
} catch (NoSuchProviderException e) {
e.printStackTrace();
System.exit(1);
} catch (MessagingException e) {
e.printStackTrace();
System.exit(2);
}

}

}

  • August 16, 2012
  • Like
  • 0

Hello guys,

 

I will like to send an auto email when a related lookup exists.

 

How do i go about it?

 

I cannot use workflow rule, as it does not support custom Object related record lookup.

 

What is the best practise and how can it be implemented i have no idea if this is possible or not.

 

Any feedback will be highly apreciated.

 

 

Regard,

Im trying to return the text of multiple xml elements with the same name. Im using Xmlnode.

 

Heres part of the code that handles the response:

 

// Get xml body from response
dom.Document docx = res.getBodyDocument();
dom.Xmlnode xroot = docx.getRootElement();
dom.Xmlnode xrec = xroot.getChildElement('error', null);

// Setup email for exception
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();            
String[] toAddress = new String[] {ownerEmail};
mail.setToAddresses(toAddress);
mail.setSenderDisplayName('Salesforce');
mail.setSubject('A problem has occured with creating the Proposal');
mail.setPlainTextBody('The following error occured when trying to create the Proposal: \n\n"Proposal ' + newError + '"\n\nPlease correct the errors above and try again.');    
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

 

The reponse would look something like:

 

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<errors>
    <error>advertiser can't be blank</error>
    <error>name can't be blank</error>
    <error>campaign_type can't be blank</error>
    <error>start_date can't be blank</error>
</errors>

 

Right now it only returns the text from the first "error" element.

 

Ive looked at the xmlnode docs, but Im having a hard time understanding how to get the text from all of the nodes.

 

Any help would be much appreciated!!


Thanks!

  • August 15, 2012
  • Like
  • 0

Hi 

I have a doubt,Please help me out...

I have created one custom object and added it to some appications..if i want to know how many appications having visibilty off this object,what should i do....

Thanks in advance....

 

 

  • August 10, 2012
  • Like
  • 0