• VKSINGH
  • NEWBIE
  • 0 Points
  • Member since 2013

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

Hi All, need ur help,

I m firing a trigger by passing id of the object that extecute the http request n response.n my getting the response also.
but i have to refresh my detail page manually ,then that response value gets set to my customfield.
I want that..when i click save then data n response value both gets saved at that time.

My trigger code is this:

 

trigger test on OpportunityGAQ__c (after insert) {

 System.debug('Making future call to update account');
 for(OpportunityGAQ__c op:Trigger.New)
 {
  GAQUpdater.updateGAQ(op.Id, op.Name);    
    }
}

 

My Apex code is this :

 

public class GAQUpdater {
 
    public GAQUpdater(ApexPages.StandardController controller) {

    }


  //Future annotation to mark the method as async.
  @Future(callout=true)
  public static void updateGAQ(String id, String name) {
    public void save(){
    // system.debug('OPP:'+id);
    //construct an HTTP request
    HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
         
        string test = 'some string';
        req.setEndpoint('http://www.test.com.aspx');
        req.setMethod('POST');
        req.setBody(test);
     
        
        res = http.send(req);  
        System.debug(res.getBody());
   
         Dom.Document doc =(res.getBodyDocument());
        Dom.XMLNode envelope = doc.getRootElement();
        Dom.XmlNode[] temp = envelope.getChildElements();
       // String name = envelope.getChildElements('OrderID', null).getText();
             system.debug(temp.size());
          // print out specific elements
        // System.debug('OrderID: ' + name);
        
        if(temp.size()>0)
        {
            // Alternatively, loop through the child elements.
            // This prints out all the elements of the address
            for(Dom.XMLNode child : temp[1].getChildElements()) {
               
                if(child.getName()=='OrderID')
                {
                   // System.debug('G Ord Id: '+child.getText());
                  OpportunityGAQ__c op = new OpportunityGAQ__c(Id=id);  
                  op.Refrence_Number__c = child.getText();                              
                  update op;  
                }
                
                else if(child.getName()=='OrderStatusErrors'){
                    
                    for(Dom.XMLNode child2 : child.getChildElements()) {
                        
                        for(Dom.XMLNode child3 : child2.getChildElements()) {
                            
                            if(child3.getName()=='ErrorText'){
                                System.debug('Error Message: '+child3.getText());
                 }

         }

     }

  }

 }

}

}

}      

Every part of the Apex controller is fine cos m getting the response n also reading that response value(order no here)

but,the Red mark area is for updating the field,this is also working n update the field (to my custom reference field) but when i manually refresh the page.

 

I have created a custom object n have 2 field,name n id of field i am passing through trigger n in reference field for response to save. I am not using VF any Pages.

 

Pls help me to this.

 

 

hi every one, need ur help

 

When i m sending the hard code xml data through http,in response i m getting the status is ok n status code is 200,but the xml data is going to the external server in some encoded form.I m not using any encoding(like UTF-8) in my code,but still the external server getting xml in encoded form. 

 

Can any one tell me,how to remove this problm,cos if the external server receives the correct xml format data it will response back to correct value,for which i m looking.

 

hello every one,

 

i have to Create a custom button on opportunity page.like when i select a picklist valuue say closed won or closed lost from Stage field in opportunity then only custom buttom will appear on the page.

 

pls help me.

 

 

Thanks

hello everyone,

 

need ur help,

 

i have to create a picklist n when i select a picklist value then a button will show, and when i click on that button google will gets open on d same page just below d button.

 

i have created d controller for picklist n picklist is coming in vf page but other funtionality which i have to do,i am not able to do that.

So pls pls help me.

 

Any help will be Highly appreciated.

 

 

hi every one, need ur help

 

When i m sending the hard code xml data through http,in response i m getting the status is ok n status code is 200,but the xml data is going to the external server in some encoded form.I m not using any encoding(like UTF-8) in my code,but still the external server getting xml in encoded form. 

 

Can any one tell me,how to remove this problm,cos if the external server receives the correct xml format data it will response back to correct value,for which i m looking.

 

hello every one,

 

i have to Create a custom button on opportunity page.like when i select a picklist valuue say closed won or closed lost from Stage field in opportunity then only custom buttom will appear on the page.

 

pls help me.

 

 

Thanks