• shiva 463
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 2
    Replies
Hi All,

Can anyone help me in building the JavaScript for refresh the page on click of Custom button in Edit page.
I have oppurtunity page in this I have craeted a new record and saved it and after the save, the page will goes to edit page.In the edit page I have Custom button to claculate the amount from 3rdparty application and I am getting the reference Id from 3rd party application on refresh of  browser or click of browser.But my requirement is not to refresh the page by myself it has to automatically refresh the page and get the Refrence ID from 3rd party application.

Intially I have achieved like this using Java script but the page is not refreshing or reloading,So can anyone help me on this issue.

Code:{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")}
var myJob = new sforce.SObject("Opportunity");
myJob.Id = "{!Opportunity.Id}";
myJob.check__c= "true";
var result = sforce.connection.update([myJob]);
setTimeout(window.location.reload(true),60000);
window.location.reload(true);
User-added image

Here is the EDIT page what iam trying to achieveUser-added image
Hi All,

Iam trying to referesh the page on click of button in detail page. I tried with the following script but get an popup error and iam getting the result finally but popup should be removed.So can any one help me on this issue.

Script:
{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")} 

var myJob = new sforce.SObject("Opportunity"); 
myJob.Id = "{!Opportunity.Id}"; 
myJob.check__c= "true"; 
var result = sforce.connection.update([myJob]); 
setTimeout(document.location.reload(true),60000); 
document.reload(true);User-added image
Hi All,
Iam trying to get the BI reports from OSC to SFDC getting an error when passing the parameters in payload.Getting an error Failed to parse XML due to: only whitespace content allowed before start tag and not P (position: START_DOCUMENT seen P... @1:1)  so can anyone help me on this issue.

Here is the code.


global class ResponseclsforCACF_report{
@future(callout=true)
    //public static void Responsefrom3rdparty(string syncid,String acc){
         public static void Responsefrom3rdparty(string syncid,String acc){
         List<String> list_report=new list<String>();
         List<FIC_Reports__c> salescomision=new List<FIC_Reports__c>();
         list<String> sos=new List<String>();
         Boolean checkval=false;
         Boolean baseco=false;
      
    //try{
     
      String endPointURL='https://xxxxxx.us2.oraclecloud.com:443/xmlpserver/services/ExternalReportWSSService?WSDL';
      String userName = 'xxxxxxxxxx';
      String password = 'xxxx';
      Blob headerValue = Blob.valueOf(userName + ':' + password);
      String authorizationHeader = 'BASIC ' +EncodingUtil.base64Encode(headerValue);
        
        //Date dd=system.today();
        //DOM.Document resDoc = new DOM.Document();        
            // Send the request
           
            
            String str=+'<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:pub="http://xmlns.oracle.com/oxp/service/PublicReportService">'
   +'<soap:Header/>'
   +'<soap:Body>'
      +'<pub:runReport>'
         +'<pub:reportRequest>'
            +'<pub:reportAbsolutePath>/Custom/Customer Relationship Management/pty_SC_DM_Report.xdo</pub:reportAbsolutePath>'
            +'<pub:sizeOfDataChunkDownload>-1</pub:sizeOfDataChunkDownload>'
         +'</pub:reportRequest>'
          +'<pub:appParams/>'
      +'</pub:runReport>'
   +'</soap:Body>'
+'</soap:Envelope>';
   
            
            //tring postXML = '{set XML body here in plain text, I only used \n for newlines}';
        HttpRequest req = new HttpRequest(); 
        req.setTimeout(120000);         
        req.setMethod('GET'); 
        req.setEndpoint(endPointURL);
        req.setHeader('Authorization', authorizationHeader);
       //req.setHeader('Content-Type', 'text/xml; charset=UTF-8');
       req.setHeader('Content-Type', 'application/soap+xml;charset=UTF-8');
        //req.setHeader('Content-length',string.valueof(postXML.length()));
        req.setBody(str);
            
        Http http = new Http();    
       Transient HttpResponse res = new HttpResponse();
        //res = http.send(req); 
          //HttpResponse res = http.send(request);  
           res = http.send(req); 
        //system.debug('res.......'+res.getbody());
        cacfQuot__c sfintegrate = new cacfQuot__c();
       /*--------syncid-----*/
        sfintegrate.SFDCQuot__c=syncid;
        sfintegrate.Name=acc;    
        sfintegrate.Request_Status__c=res.getStatus();
         sfintegrate.Status_Code__c=string.valueof(res.getStatusCode());    
         sfintegrate.FIC_response__c=res.getbody();
         if(sfintegrate.Status_Code__c!='200'){       
         sfintegrate.FIC_response__c=res.getbody();
         system.debug('00000000000'+res.getbody());
        
         }
         sfintegrate.Execution_time__c=string.valueof(System.now());
         sfintegrate.Request_Body__c=str;   
               if(res.getStatusCode() ==200){     
              String encodedvalue;
              string decodedstring ;
       Dom.Document docx = new Dom.Document();
       docx.load(res.getbody());
    system.debug('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'+res.getbody());
    
    
       dom.XmlNode xroot = docx.getrootelement() ;
       //system.debug('xroot..'+xroot);
        dom.XmlNode [] xrec = xroot.getchildelements() ;
        
    for(Dom.XMLNode child : xrec) {

    //system.debug('child..'+child);
        for (dom.XmlNode awr : child.getchildren() ) {
        //System.debug('awr...'+awr);
            for(dom.XmlNode xy:awr.getchildren()){
            // system.debug('xy...'+xy);
                for(dom.XmlNode anc :xy.getchildren()){


                 //if(anc.gettext() != null ){
                 baseco=true;
                encodedvalue=anc.gettext();
                 
                    //encodedvalue=encodedvalue.replace(';',' '); 
                    
                    /*Blob d = EncodingUtil.base64Decode(encodedvalue);
                        //system.debug('d...'+d);
                    decodedstring = d.tostring();*/
                    Blob d= Blob.valueof(encodedvalue);
                    decodedstring =d.tostring();
                    system.debug('@@@@@@@@@@'+decodedstring );
               /* }
                
            }
          
        }
       
    }*/
        
            
            /******************this Dom.XMLstring***************/
        Dom.Document docxxml = new Dom.Document();
                     docxxml.load(decodedstring);
    dom.XmlNode xrootxml = docxxml.getrootelement() ;
            
    for(Dom.XMLNode child_rep: xrootxml.getChildElements()) {
        //  System.debug('head....'+child);
        for(Dom.XMLNode child1:child_rep.getChildElements()){
            // system.debug('body..'+child1);
            for(Dom.XMLNode child2:child1.getChildElements()){
            //list_report.clear();
               FIC_Reports__c salescom = new FIC_Reports__c();
              
                //    System.debug('tr....'+child2);
                for(Dom.XMLNode child3:child2.getChildElements()){
                    // System.debug('td...'+child3);
                    for(Dom.XMLNode child4:child3.getChildElements()){
                        //  System.debug('p....'+child4);
                        
                        for(Dom.XMLNode child5:child4.getChildElements()){
                            system.debug('@@@@@'+child5.getname());
                            if(child5.getname() == 'span'){
                           checkval=true;
                            system.debug('child5...'+child5.gettext());
                            list_report.add(child5.gettext());
                            system.debug('#########'+list_report);
                            }
                        }
                    }
                
                } 
                          
                   for(string ss:list_report){
                           if(list_report.size()==2)
                              
                             {
                                   checkval=true;
                               }
                               else{
                                   checkval=false;
                               }
                  }
                   
               if(checkval==true){
                   system.debug('Valuestoaddintrue.........'+list_report);
                   
                 
                   salescom.Name=list_report[1];
                   salescom.Description__c=list_report[0];
                  
                   salescomision.add(salescom);
                   //insert salescom;
               
               //checkval=false;
                system.debug('^^^^^^salescommision'+salescomision);
               system.debug('^^^^^^salescommision'+salescomision.size());
                   
               }
                     
                    
                   
               }   
              
         
               insert salescomision;
               
               system.debug('salescomisionsales.............'+salescomision);
               
            }
        }
        
        }}}}
       
   
        
        system.debug('salescomisionsales.............'+salescomision);
   
        }
       }
    }
 
Hi All,

Can anyone help me in building the JavaScript for refresh the page on click of Custom button in Edit page.
I have oppurtunity page in this I have craeted a new record and saved it and after the save, the page will goes to edit page.In the edit page I have Custom button to claculate the amount from 3rdparty application and I am getting the reference Id from 3rd party application on refresh of  browser or click of browser.But my requirement is not to refresh the page by myself it has to automatically refresh the page and get the Refrence ID from 3rd party application.

Intially I have achieved like this using Java script but the page is not refreshing or reloading,So can anyone help me on this issue.

Code:{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")}
var myJob = new sforce.SObject("Opportunity");
myJob.Id = "{!Opportunity.Id}";
myJob.check__c= "true";
var result = sforce.connection.update([myJob]);
setTimeout(window.location.reload(true),60000);
window.location.reload(true);
User-added image

Here is the EDIT page what iam trying to achieveUser-added image
Hi All,

Iam trying to referesh the page on click of button in detail page. I tried with the following script but get an popup error and iam getting the result finally but popup should be removed.So can any one help me on this issue.

Script:
{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")} 

var myJob = new sforce.SObject("Opportunity"); 
myJob.Id = "{!Opportunity.Id}"; 
myJob.check__c= "true"; 
var result = sforce.connection.update([myJob]); 
setTimeout(document.location.reload(true),60000); 
document.reload(true);User-added image