• manoj6492
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 4
    Replies
Hi all,
          Im trying get the   session ID of another user in the same org using the sOAP .But when i send the request Im getting MIssing SOAP action header as error message .But for that request SOAP action is blank in wsdl file generated from my Developer edition.The following is the request im sending to salesforce server
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com">
   <soapenv:Header>
      <urn:organizationId>xxxxxxx</urn:organizationId>
   </soapenv:Header>
   <soapenv:Body>
      <urn:login>
         <urn:username>xxxxxxxxx</urn:username>
         <urn:password>xxxxxxxxx</urn:password>
      </urn:login>
   </soapenv:Body>
</soapenv:Envelope>

Hi devos,

When i try to view the contact (lookup)  for the portal user in the user object where the user is related to person account  i am getting the following error  in the prepod sandbox
Insufficient Privileges You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary.
 
But i have implemented the same in developer sandbox there its working fine.I have same security settings in both of the sandox .I couldnt figure out the  solution. It will be grt if some come up wt some ideas

How to start developing hybrid app from the scratch?I read lot of blogs regarding this but none of the blog provided the right solution....I tried phone gap but the apk hich was delivered using phonegap doesn't perform any operation it acts just like an image..Can anyone guide me in this processs...

Hi,

       I am a trainee in sales force development ,When i was trying to find examples for wrapper class i couldnt find much most of them were based on  visualforce.I have posted a code for better understanding about wrapper class for the beginners.

@RestResource(urlMapping='/MyAccount/*')
global with sharing class wrapper
{
    @HttpGet
    global static  string MyAccount()
    {
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response; 
        list<Account> acc = [Select name ,Id, (Select  name, Email from Contacts)From Account  where ActiveStatus__c=true];
        list<Accountw> aw = new list<Accountw>();
          
        for(Account ac :acc)
        {
             system.debug('ac1');
             list<ContactW> con= new list<ContactW> ();
             system.debug('newlis:'+con);
             for(contact c :ac.Contacts)
                {   
                    system.debug('contact>>'+c);
                    contactW c1 = new contactW(c.name,c.email);
                    con.add(c1);
      
                }
           
             Accountw a = new Accountw(ac.Id,ac.name,con);
             aw.add(a);           
            
        }system.debug('the list :'+Json.serialize(aw));
     return Json.serialize(aw);
    }
   global class Accountw
    { 
        string Ids{get;set;}
        string Name1{get;set;}
        list<contactW> con{get;set;}
        Accountw(String id,string name,list<contactW> con1)
        {
            Ids=id;
            Name1=name;
            con= con1;
        }
    }
    class contactW
    {
        string cname{get;set;}
        string Email1{get;set;}
         contactW(string name ,string  email)
        {
            cname = name;
            Email1 = email;
        }
    }
}

 I this code i have used REST ,JSON and Wrapper class

trigger AccountReplicate on Account (after delete, after insert, after update) {

if(trigger.isInsert)
{
for (Account acc:trigger.new)
{
    AccountOne__c ac = new AccountOne__c();
    ac.Fax__c = acc.Fax;
    ac.Phone__c = acc.Phone;
    ac.Name =acc.Name;
    insert ac;
}
	
}

if(trigger.isUpdate)

{
	
		
		integer i=0;
	list<AccountOne__c> a2 = new list<AccountOne__c>([Select Id from AccountOne__c where Name =: trigger.old[i].Name ]);
	
	for(AccountOne__c c1 : a2)
	{	
	
		
		c1.Name=trigger.new[i].name;
		c1.Fax__C =trigger.new[i].Fax;
		c1.Phone__C=trigger.new[i].Phone;
		i++;
		
		
	}
		update a2;
		
}
if(trigger.isDelete)
{
	AccountOne__c a3 = [Select Id from AccountOne__c where Name =: trigger.old[0].Name ];		
	
	
		delete a3;
}
}

 the above trigger handles only single record but i need to handle it for bulk records...can anyone help me

hi

import com.sforce.soap.enterprise.Connector;
import com.sforce.soap.enterprise.DeleteResult;
import com.sforce.soap.enterprise.EnterpriseConnection;
import com.sforce.soap.enterprise.Error;
import com.sforce.soap.enterprise.QueryResult;
import com.sforce.soap.enterprise.SaveResult;
import com.sforce.soap.enterprise.sobject.Account;
import com.sforce.soap.enterprise.sobject.Contact;
import com.sforce.ws.ConnectionException;
import com.sforce.ws.ConnectorConfig;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

public class Attachment {
static final String USERNAME = "XXXX";
static final String PASSWORD = "XXXX";
  static EnterpriseConnection connection;

  public static void main(String[] args) {

    ConnectorConfig config = new ConnectorConfig();
    config.setUsername(USERNAME);
    config.setPassword(PASSWORD);
    //config.setTraceMessage(true);

    try {

      connection = Connector.newConnection(config);

      // display some current settings
      System.out.println("Auth EndPoint: "+config.getAuthEndpoint());
      System.out.println("Service EndPoint: "+config.getServiceEndpoint());
      System.out.println("Username: "+config.getUsername());
      System.out.println("SessionId: "+config.getSessionId());

      // run the different examples
        createAttachment();
    // createAccounts();
      //updateAccounts();
     // deleteAccounts();


    } catch (ConnectionException e1) {
        e1.printStackTrace();
    }  

  }
  public static void createAttachment()
  {try {

        File f = new File("c:\\java\\test.docx");
        InputStream is = new FileInputStream(f);
        byte[] inbuff = new byte[(int)f.length()];        
        is.read(inbuff);

        Attachment attach = new Attachment();
        attach.setBody(inbuff);
        attach.setName("test.docx");
        attach.setIsPrivate(false);
        // attach to an object in SFDC 
        attach.setParentId("a0f600000008Q4f");

        SaveResult sr = binding.create(new com.sforce.soap.enterprise.sobject.SObject[] {attach})[0];
        if (sr.isSuccess()) {
            System.out.println("Successfully added attachment.");
        } else {
            System.out.println("Error adding attachment: " + sr.getErrors(0).getMessage());
        }


    } catch (FileNotFoundException fnf) {
        System.out.println("File Not Found: " +fnf.getMessage());

    } catch (IOException io) {
        System.out.println("IO: " +io.getMessage());            
    }
  }

 I am tryin to add an attachment but my code asks me to create methods for setbody,setname...y should i create methods for that....anyone can help me ...

@RestResource(urlMapping='/MyAccount/*')
global with sharing class wrapper
{
    @HttpGet
    global static String MyAccount()
    {
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response; 
        list<Account> acc = [Select name ,Id, (Select Id, lastname from Contacts)From Account limit 10];
        list<Accountw> aw = new list<Accountw>();
        list<ContactW> con= new list<ContactW> ();
        for(Account ac :acc)
        {
            
            for(contact c :ac.Contacts)
            	{
                    contactW c1 = new contactW(c.name,c.Email);
                    con.add(c1);
            	}
            Accountw a = new Accountw(ac.id,ac.name,con);
           aw.add(a);   
        }
    
        return JSON.serialize(aw);
    }
    class Accountw
    { 
        string Ids{get;set;}
        string Name{get;set;}
        list<contactW> con{get;set;}
        Accountw(String ids,string name,list<contactW> con1)
        {
        	Ids=ids;
         	Name=name;
         	con= con1;
        }
    }
    class contactW
    {
        string cname{get;set;}
        string Email{get;set;}
         contactW(string name ,string  Email)
        {
            cname = name;
            Email = Email;
        }
    }
}

 when i execut this code i get the following error:

                                                                   

  • message: System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Contact.Name Class.wrapper.MyAccount: line 17, column 1
  • errorCode: APEX_ERROR

what changes should be done in order to overcome this error

Hi,

I  want to know how to use wrapper class in apex,without using the visual force page. Actually I have a task To dispaly the Account whose activstatus is checked(custom fiels) and its contacts Using the REST services and output should be in JSON .Withoud using any id or name when i execute the Get method ,system should display all the accounts and its contacts as per the condition.

 

why a developer might need direct access to the RESTRequest object?

hi,

    Can anyone give detailed explanation about the usage of Rest response and Rest request in the rest services

Hi devos,

When i try to view the contact (lookup)  for the portal user in the user object where the user is related to person account  i am getting the following error  in the prepod sandbox
Insufficient Privileges You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary.
 
But i have implemented the same in developer sandbox there its working fine.I have same security settings in both of the sandox .I couldnt figure out the  solution. It will be grt if some come up wt some ideas
trigger AccountReplicate on Account (after delete, after insert, after update) {

if(trigger.isInsert)
{
for (Account acc:trigger.new)
{
    AccountOne__c ac = new AccountOne__c();
    ac.Fax__c = acc.Fax;
    ac.Phone__c = acc.Phone;
    ac.Name =acc.Name;
    insert ac;
}
	
}

if(trigger.isUpdate)

{
	
		
		integer i=0;
	list<AccountOne__c> a2 = new list<AccountOne__c>([Select Id from AccountOne__c where Name =: trigger.old[i].Name ]);
	
	for(AccountOne__c c1 : a2)
	{	
	
		
		c1.Name=trigger.new[i].name;
		c1.Fax__C =trigger.new[i].Fax;
		c1.Phone__C=trigger.new[i].Phone;
		i++;
		
		
	}
		update a2;
		
}
if(trigger.isDelete)
{
	AccountOne__c a3 = [Select Id from AccountOne__c where Name =: trigger.old[0].Name ];		
	
	
		delete a3;
}
}

 the above trigger handles only single record but i need to handle it for bulk records...can anyone help me

@RestResource(urlMapping='/MyAccount/*')
global with sharing class wrapper
{
    @HttpGet
    global static String MyAccount()
    {
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response; 
        list<Account> acc = [Select name ,Id, (Select Id, lastname from Contacts)From Account limit 10];
        list<Accountw> aw = new list<Accountw>();
        list<ContactW> con= new list<ContactW> ();
        for(Account ac :acc)
        {
            
            for(contact c :ac.Contacts)
            	{
                    contactW c1 = new contactW(c.name,c.Email);
                    con.add(c1);
            	}
            Accountw a = new Accountw(ac.id,ac.name,con);
           aw.add(a);   
        }
    
        return JSON.serialize(aw);
    }
    class Accountw
    { 
        string Ids{get;set;}
        string Name{get;set;}
        list<contactW> con{get;set;}
        Accountw(String ids,string name,list<contactW> con1)
        {
        	Ids=ids;
         	Name=name;
         	con= con1;
        }
    }
    class contactW
    {
        string cname{get;set;}
        string Email{get;set;}
         contactW(string name ,string  Email)
        {
            cname = name;
            Email = Email;
        }
    }
}

 when i execut this code i get the following error:

                                                                   

  • message: System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Contact.Name Class.wrapper.MyAccount: line 17, column 1
  • errorCode: APEX_ERROR

what changes should be done in order to overcome this error

Sorry, the previous two messages were sent out by accidental key stokes.  Here is the question again:
 
I recently migrated my Ajax scontrol to the new Winter '07 release and started to get the following error message when making queries to my company data in SFDC:
 
       {faultcode:'soapenv:Client', faultstring:'SOAPAction HTTP header missing',}
 
The query was simple as "select ... from ... where...".
I never saw this before even in the prerelease.  I don't think we need to set the SOAP header everytime we call the sforce.connection.query(...).  But why I am getting this error.  If anyone has similar experience and know how to get rid of this error, please respond.
 
Best Regards,