• bayside
  • NEWBIE
  • 0 Points
  • Member since 2005

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Hello.

I had installed WWW::Salesforce, and I tried to call delete api, but some error occurred.
Please give me a hint to resolve this problem.

This is test code.

#!/usr/bin/perl

package SFDCCleaner;

use strict;
use warnings;
use WWW::Salesforce;
use Data:: Dumper;

sub sforce_login {
    my $self = shift;
    my $user = shift;
    my $pass = shift;
    my $port = WWW::Salesforce->new(
        'username' => $user,
        'password' => $pass) || die "could not login to salesforce.com";
    return $port;
}

sub delete_object_multi {
    my($self, $port, $result) = @_;
    my @ids;
    foreach my $obj ($result->valueof('//queryResponse/result/records')) {
        printf("removing %s at %s ...\n", $obj->{'Id'}, $obj->{'type'});
        push(@ids, $obj->{'Id'});
    }
    my $res = $port->delete(@ids);
    print Dumper $res;
}

sub sforce_clear_leads {
    my($self, $port) = @_;

    my $result = $port->query(query => 'select id from Lead', limit => 1);
    my $size = $result->valueof('//queryResponse/result')->{'size'};
    for (my $i = 0; $i < ($size / 100); $i++) {
        $result = $port->query(query => 'select id from Lead', limit => 100);
        $self->delete_object_multi($port, $result);
    }
    $result = $port->query(query => 'select id from Lead', limit => ($size % 100));
    $self->delete_object_multi($port, $result);
}

1;

package main;

my $port = SFDCCleaner->sforce_login('foo@bar', 'foobar');
SFDCCleaner->sforce_clear_leads($port);

ErrorMessage:

$VAR1 = bless( {
   '_content' => [
     'soapenv:Envelope',
     {
       'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
       'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema',
       'xmlns:soapenv' => 'http://schemas.xmlsoap.org/soap/envelope/'
     },
     [
       [
         'soapenv:Body',
         {},
         [
           [
      'soapenv:Fault',
      {},
      [
        [
          'faultcode',
          {
            'xmlns:ns1' => 'http://xml.apache.org/axis/'
          },
          'ns1:Server.NoService',
          undef,
          'ns1:Server.NoService',
          'faultcode',
          {}
        ],
        [
          'faultstring',
          {},
          'The AXIS engine could not find a target service to invoke!  targetService is u/6.0',
          undef,
          'The AXIS engine could not find a target service to invoke!  targetService is u/6.0',
          'faultstring',
          {}
        ],
        [
          'detail',
          {},
          '',
          undef,
          '',
          'detail',
          {}
        ]
      ],
      undef,
      {
        'detail' => '',
        'faultcode' => 'ns1:Server.NoService',
        'faultstring' => 'The AXIS engine could not find a target service to invoke!  targetService is u/6.0'
      },
      '{http://schemas.xmlsoap.org/soap/envelope/}Fault',
      {}
           ]
         ],
         undef,
         {
           'Fault' => $VAR1->{'_content'}[2][0][2][0][4]
         },
         '{http://schemas.xmlsoap.org/soap/envelope/}Body',
         {}
       ]
     ],
     undef,
     {
       'Body' => $VAR1->{'_content'}[2][0][4]
     },
     '{http://schemas.xmlsoap.org/soap/envelope/}Envelope',
     {}
          ],
   '_current' => [
     $VAR1->{'_content'}
          ]
        }, 'SOAP::SOM' );

Thanks.

Message Edited by bayside on 03-30-2006 01:48 AM

I am trying to  create an attachment using perl and the API. I am base64 encoding the string using MIME::Base64's encode_base64 method. Here's my create call:

        my $r = $sf->create( type=>'Attachment',
                    Body => "$filedata",
                    Name => "$uploaded_filename",
                    ParentId => "$caseid"
                    );

Here's what I get back:

$VAR1 = { 'success' => 'false', 'errors' => { 'fields' => undef, 'statusCode' => 'INVALID_TYPE_ON_FIELD_IN_RECORD', 'message' => 'Body: value not of required type: VGhpcyBpcyBhIHRlc3QgZm9yIHRoZSBhdHRhY2htZW50IGZlYXR1cmUuIE5vdCBjb21wcmVzc2lu ZyBiZWZvcmUgaW5zZXJ0IHlldC4=' }, 'id' => undef };

Can someone help please?
  • April 07, 2006
  • Like
  • 0