• Madhu3006
  • NEWBIE
  • 0 Points
  • Member since 2013

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

Hi Everyone,

 

I am new to ajax tool kit.

The code works fine,since i am using the log to write the log .

But the log are not getting displayed in debug logs.

Where to see that logs can any one help me out

 

Thanks

 

 

<apex:page >

<script type="text/javascript">
var __sfdcSessionId = '{!GETSESSIONID()}';
alert( __sfdcSessionId);
</script>
<script src="../../soap/ajax/27.0/connection.js"
type="text/javascript"></script>
<script type="text/javascript">

window.onload = setupPage;
function setupPage()
{
try{
result = sforce.connection.query("Select Name, Id from Account");

records = result.getArray("records");
for (var i=0; i< records.length; i++) {
var record = records[i];
alert(record.Name + " -- " + record.Id);
log(record.Name + " -- " + record.Id);
}
}catch(error) {
if (error.faultcode.indexOf("INVALID_QUERY_SCOPE") != -1) {
log("check for the query");
} else {
log(error);
}
}

}
</script>
<div id="output"> </div>

</apex:page>

Hi Every One,

 

I wrote the code ,it works fine if the account is having opportunites.

some times there wont be an opportunities that have associated to Accounts

at that point of time.the code fails

here is the query what i am using

QueryResult rs =binding.query("SELECT Id,Name,(SELECT Name,Id FROM Opportunities )FROM Account where id='0019000000NR6Dg' ");

 

 

package com.sforce.enterprise.javaclass;

import java.lang.reflect.Field;
import java.rmi.RemoteException;

import javax.xml.rpc.ServiceException;

import org.apache.axis.wsdl.symbolTable.FaultInfo;

import com.sforce.async.QueryResultList;
import com.sforce.soap.enterprise.LoginResult;
import com.sforce.soap.enterprise.Logout;
import com.sforce.soap.enterprise.QueryResult;
import com.sforce.soap.enterprise.SessionHeader;
import com.sforce.soap.enterprise.SforceServiceLocator;
import com.sforce.soap.enterprise.SoapBindingStub;
import com.sforce.soap.enterprise.fault.LoginFault;
import com.sforce.soap.enterprise.fault.UnexpectedErrorFault;
import com.sforce.soap.enterprise.sobject.Account;
import com.sforce.soap.enterprise.sobject.Case;
import com.sforce.soap.enterprise.sobject._case;
import com.sforce.soap.enterprise.sobject.CaseHistory;
import com.sforce.soap.enterprise.sobject.Contact;
import com.sforce.soap.enterprise.sobject.Opportunity;
import com.sforce.soap.enterprise.sobject.SObject;
import com.sforce.soap.enterprise.sobject.SObject.*;

public class ParentChildQuery {

private static final SObject ParentChildQuery = null;
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub

ParentChildQuery _cntQuery=new ParentChildQuery();
try {
_cntQuery.queryChildRec();
} catch (UnexpectedErrorFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (LoginFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ServiceException e) {
// TODO Auto-generated catch block
e.printStackTrace();

}
}

public void queryChildRec() throws UnexpectedErrorFault, LoginFault,
RemoteException, ServiceException
{
try
{
SoapBindingStub binding= (SoapBindingStub) new SforceServiceLocator().getSoap();
LoginResult lr=binding.login("XXx", "XXX");
//Reset the binding to use the endpoint returned from login
String Seid=lr.getSessionId();
System.out.println("seesion Id is"+Seid);
binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY, lr.getServerUrl());
//Create the session id header, and add it to the proxy binding
SessionHeader sh=new SessionHeader();
SessionHeader shd=new SessionHeader();
shd.setSessionId(Seid);
sh.setSessionId(lr.getSessionId());
System.out.println();
binding.setHeader(new SforceServiceLocator().getServiceName().getNamespaceURI(),"SessionHeader",sh);
//String res="SELECT LastName,(SELECT Name FROM Opportunities )FROM Contact Where SendtoSAP__c=TRUE";
//QueryResult rs =binding.query("SELECT FirstName, LastName,(SELECT Name,Id FROM Opportunities where StageName='Prospecting' )FROM Contact Where SendtoSAP__c=TRUE ");
//QueryResult rs =binding.query("SELECT FirstName, LastName,(SELECT Name,Id FROM Opportunities )FROM Contact Where SendtoSAP__c=TRUE ");
QueryResult rs =binding.query("SELECT Id,Name,(SELECT Name,Id FROM Opportunities )FROM Account where id='0019000000NR6Dg' ");

//QueryResult rs =binding.query("SELECT CaseNumber,Id,AccountId FROM Case where AccountId != null"); //SaveResult rs=binding.create(sObjects)
SObject So=rs.getRecords()[0];
System.out.println("Lenght of the records" +rs.getSize());
//Contact =(Contact)(So.getId());
int loopCount = 0;
boolean done = false;
while(!done)
{
SObject[] records = rs.getRecords();
for (int i = 0; i < records.length; i++) {
Account acct=(Account) records[i];
//Contact contact =(Contact) records[i];
String fName=acct.getName();
String lName=acct.getId();
//String _cntid=contact.getId();
//Integer optynmae=acct.getCases().getSize();
//System.out.println("TOtal Cases that are associated to Account -------"+optynmae);
String optyname1 = null;
String optyId=null;
SObject [] oprtrecords = null;
QueryResult optyname=acct.getOpportunities();
System.out.println("optysize" +optyname.getSize());
if(optyname.getSize()>0)
{
int j = 0;
oprtrecords=optyname.getRecords();
for( j=0;j<oprtrecords.length;j++)

{



Opportunity casesrec= (Opportunity) oprtrecords[j];
String acctidincases=casesrec.getAccountId();
// if(acctidincases.isEmpty()&& acctidincases!=null){
//Case opty=(Case) oprtrecords[j];
optyname1= casesrec.getName();
optyId = casesrec.getId();
//casesrec.getAccountId()

System.out.println("Casenumber-------" +optyname1+"CaseId---------"+optyId);
//}


}
}
else{
System.out.println("No Asscocaited Opty for this account");
}
if (fName==null) {
System.out.println("AccountName " + (i + 1) + "CoditionPrinted " + lName);
} else {
System.out.println("Accountid " + (i + 1) + ": " + fName
+ " " + lName);
}
if (rs.isDone()) {
done = true;
} else
{
rs = binding.queryMore(rs.getQueryLocator());
}
System.out.println("\nQuery succesfully executed.");

}
}

binding.clearHeaders();
binding.setHeader(new SforceServiceLocator().getServiceName().getNamespaceURI(),"SessionHeader", sh);
}catch(Exception e)
{
System.out.println(e.getMessage());

}


}

}

 

Please suggets me how to proceed.

regards

Madhu

Hi Every One,

 

I wrote the code ,it works fine if the account is having opportunites.

some times there wont be an opportunities that have associated to Accounts

at that point of time.the code fails

here is the query what i am using

QueryResult rs =binding.query("SELECT Id,Name,(SELECT Name,Id FROM Opportunities )FROM Account where id='0019000000NR6Dg' ");

 

 

package com.sforce.enterprise.javaclass;

import java.lang.reflect.Field;
import java.rmi.RemoteException;

import javax.xml.rpc.ServiceException;

import org.apache.axis.wsdl.symbolTable.FaultInfo;

import com.sforce.async.QueryResultList;
import com.sforce.soap.enterprise.LoginResult;
import com.sforce.soap.enterprise.Logout;
import com.sforce.soap.enterprise.QueryResult;
import com.sforce.soap.enterprise.SessionHeader;
import com.sforce.soap.enterprise.SforceServiceLocator;
import com.sforce.soap.enterprise.SoapBindingStub;
import com.sforce.soap.enterprise.fault.LoginFault;
import com.sforce.soap.enterprise.fault.UnexpectedErrorFault;
import com.sforce.soap.enterprise.sobject.Account;
import com.sforce.soap.enterprise.sobject.Case;
import com.sforce.soap.enterprise.sobject._case;
import com.sforce.soap.enterprise.sobject.CaseHistory;
import com.sforce.soap.enterprise.sobject.Contact;
import com.sforce.soap.enterprise.sobject.Opportunity;
import com.sforce.soap.enterprise.sobject.SObject;
import com.sforce.soap.enterprise.sobject.SObject.*;

public class ParentChildQuery {

private static final SObject ParentChildQuery = null;
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub

ParentChildQuery _cntQuery=new ParentChildQuery();
try {
_cntQuery.queryChildRec();
} catch (UnexpectedErrorFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (LoginFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ServiceException e) {
// TODO Auto-generated catch block
e.printStackTrace();

}
}

public void queryChildRec() throws UnexpectedErrorFault, LoginFault,
RemoteException, ServiceException
{
try
{
SoapBindingStub binding= (SoapBindingStub) new SforceServiceLocator().getSoap();
LoginResult lr=binding.login("XXx", "XXX");
//Reset the binding to use the endpoint returned from login
String Seid=lr.getSessionId();
System.out.println("seesion Id is"+Seid);
binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY, lr.getServerUrl());
//Create the session id header, and add it to the proxy binding
SessionHeader sh=new SessionHeader();
SessionHeader shd=new SessionHeader();
shd.setSessionId(Seid);
sh.setSessionId(lr.getSessionId());
System.out.println();
binding.setHeader(new SforceServiceLocator().getServiceName().getNamespaceURI(),"SessionHeader",sh);
//String res="SELECT LastName,(SELECT Name FROM Opportunities )FROM Contact Where SendtoSAP__c=TRUE";
//QueryResult rs =binding.query("SELECT FirstName, LastName,(SELECT Name,Id FROM Opportunities where StageName='Prospecting' )FROM Contact Where SendtoSAP__c=TRUE ");
//QueryResult rs =binding.query("SELECT FirstName, LastName,(SELECT Name,Id FROM Opportunities )FROM Contact Where SendtoSAP__c=TRUE ");
QueryResult rs =binding.query("SELECT Id,Name,(SELECT Name,Id FROM Opportunities )FROM Account where id='0019000000NR6Dg' ");

//QueryResult rs =binding.query("SELECT CaseNumber,Id,AccountId FROM Case where AccountId != null"); //SaveResult rs=binding.create(sObjects)
SObject So=rs.getRecords()[0];
System.out.println("Lenght of the records" +rs.getSize());
//Contact =(Contact)(So.getId());
int loopCount = 0;
boolean done = false;
while(!done)
{
SObject[] records = rs.getRecords();
for (int i = 0; i < records.length; i++) {
Account acct=(Account) records[i];
//Contact contact =(Contact) records[i];
String fName=acct.getName();
String lName=acct.getId();
//String _cntid=contact.getId();
//Integer optynmae=acct.getCases().getSize();
//System.out.println("TOtal Cases that are associated to Account -------"+optynmae);
String optyname1 = null;
String optyId=null;
SObject [] oprtrecords = null;
QueryResult optyname=acct.getOpportunities();
System.out.println("optysize" +optyname.getSize());
if(optyname.getSize()>0)
{
int j = 0;
oprtrecords=optyname.getRecords();
for( j=0;j<oprtrecords.length;j++)

{



Opportunity casesrec= (Opportunity) oprtrecords[j];
String acctidincases=casesrec.getAccountId();
// if(acctidincases.isEmpty()&& acctidincases!=null){
//Case opty=(Case) oprtrecords[j];
optyname1= casesrec.getName();
optyId = casesrec.getId();
//casesrec.getAccountId()

System.out.println("Casenumber-------" +optyname1+"CaseId---------"+optyId);
//}


}
}
else{
System.out.println("No Asscocaited Opty for this account");
}
if (fName==null) {
System.out.println("AccountName " + (i + 1) + "CoditionPrinted " + lName);
} else {
System.out.println("Accountid " + (i + 1) + ": " + fName
+ " " + lName);
}
if (rs.isDone()) {
done = true;
} else
{
rs = binding.queryMore(rs.getQueryLocator());
}
System.out.println("\nQuery succesfully executed.");

}
}

binding.clearHeaders();
binding.setHeader(new SforceServiceLocator().getServiceName().getNamespaceURI(),"SessionHeader", sh);
}catch(Exception e)
{
System.out.println(e.getMessage());

}


}

}

 

Please suggets me how to proceed.

regards

Madhu

Hi Everone,

I wrote this code for scheduler class ,but when i look in below path
 Setup->Monitoring->Scheduled Jobs i am not able be to see my class .


global class Schecudlertestaccount22  implements Schedulable  {
    Schecudlertestaccount22  c = new Schecudlertestaccount22();
    global void execute(SchedulableContext ctx) {
        
        String sch = '0 6 * * * ? ';
        
        system.schedule('Schecudlertestaccount', sch, c);
        
        Account acct= new Account();
        //acct.Type
        acct=[SELECT id, Type from Account where Type='Other'];
        acct.Site='www.abc.com';
        update acct;
    }

}

Can any one pl suggets on this


Regards
madhu

Hi Everyone

I want to query the parent child relation how can i do it,

Can please some one share the idea and the code is below.

Please suggest what i was missing.

 

package com.sforce.soap.classes;

import java.rmi.RemoteException;

import javax.xml.rpc.ServiceException;

import com.sforce.soap.enterprise.LoginResult;
import com.sforce.soap.enterprise.QueryResponse;
import com.sforce.soap.enterprise.QueryResult;
import com.sforce.soap.enterprise.SessionHeader;
import com.sforce.soap.enterprise.SforceServiceLocator;
import com.sforce.soap.enterprise.SoapBindingStub;
import com.sforce.soap.enterprise.fault.LoginFault;
import com.sforce.soap.enterprise.fault.UnexpectedErrorFault;
import com.sforce.soap.enterprise.sobject.Account;
import com.sforce.soap.enterprise.sobject.Contact;
import com.sforce.soap.enterprise.sobject.SObject;

public class ParentchildRelation {
    
    static ParentchildRelation _childQuery;
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        _childQuery=new ParentchildRelation();
        try{
            _childQuery.childQuery(null);
        }catch (Exception e) {
            // TODO: handle excebinption
            e.printStackTrace();
        }
    }
    
    public SObject childQuery(QueryResult qrP2C2) throws UnexpectedErrorFault, LoginFault,
    RemoteException
    {
        SoapBindingStub binding;
        try {
            binding = (SoapBindingStub) new SforceServiceLocator().getSoap();
            LoginResult _lr=binding.login("madhu3006@gmail.com", "Ni@$3006VrI8LOopmy4E8NIk7kn4ioMx");
            String seessionid=_lr.getSessionId();
            System.out.println("Seesion ID"+seessionid);
            binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY, _lr.getServerUrl());
            SessionHeader sh=new SessionHeader();
            sh.setSessionId(_lr.getSessionId());
            System.out.println();
            binding.setHeader(new SforceServiceLocator().getServiceName().getNamespaceURI(),"SessionHeader",sh);
            //String query1="SELECT Name,(SELECT firstname,lastname from Contacts) from Account";
            QueryResult qrP2C = binding.queryMore("SELECT Name,(SELECT firstname,lastname from Contacts) from Account LIMIT 1");
            //SObject SoResult=qrP2C.getRecords()[0];
            //QueryResult subqr=(QueryResult)(((Object) SoResult).get_any()[0].getObjectValue());
            //QueryResult subQR = (QueryResult)(SoResult.get_any()[0].getObjectValue());
            //QueryResult subQR = (QueryResult)(SoResult.getClass().g);
            //String na
            //binding.queryAll(query1);
            
            //QueryResult subr=SoResult.getClass().getName();
            ParentchildRelation _acct1= new ParentchildRelation();
          SObject test= _acct1.childQuery(qrP2C);
          String name=test.getClass().getName();
          System.out.println("Test Name"+name);
           
           
           
        //   System.out.println("Account Name is "+acctname);
           Contact _cont=new Contact();
           String fname=_cont.getFirstName();
           System.out.println("Contact FirstName is "+fname);
           String lname=_cont.getLastName();
           System.out.println("Contact LastName is "+lname);
           binding.clearHeaders();
           binding.setHeader(new SforceServiceLocator().getServiceName().getNamespaceURI(),"SessionHeader", sh);
        } catch (ServiceException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return null;
        
        
    }

}
 Regards

Madhu

Hi Everyone,

 

I am new to ajax tool kit.

The code works fine,since i am using the log to write the log .

But the log are not getting displayed in debug logs.

Where to see that logs can any one help me out

 

Thanks

 

 

<apex:page >

<script type="text/javascript">
var __sfdcSessionId = '{!GETSESSIONID()}';
alert( __sfdcSessionId);
</script>
<script src="../../soap/ajax/27.0/connection.js"
type="text/javascript"></script>
<script type="text/javascript">

window.onload = setupPage;
function setupPage()
{
try{
result = sforce.connection.query("Select Name, Id from Account");

records = result.getArray("records");
for (var i=0; i< records.length; i++) {
var record = records[i];
alert(record.Name + " -- " + record.Id);
log(record.Name + " -- " + record.Id);
}
}catch(error) {
if (error.faultcode.indexOf("INVALID_QUERY_SCOPE") != -1) {
log("check for the query");
} else {
log(error);
}
}

}
</script>
<div id="output"> </div>

</apex:page>

Hi Everone,

I wrote this code for scheduler class ,but when i look in below path
 Setup->Monitoring->Scheduled Jobs i am not able be to see my class .


global class Schecudlertestaccount22  implements Schedulable  {
    Schecudlertestaccount22  c = new Schecudlertestaccount22();
    global void execute(SchedulableContext ctx) {
        
        String sch = '0 6 * * * ? ';
        
        system.schedule('Schecudlertestaccount', sch, c);
        
        Account acct= new Account();
        //acct.Type
        acct=[SELECT id, Type from Account where Type='Other'];
        acct.Site='www.abc.com';
        update acct;
    }

}

Can any one pl suggets on this


Regards
madhu

Hi All,

 

 

I need to create a webservice class which need to be  invoked and an account should be created in the account object..

 

 

Thanks In Advance,

SFDCIANE