You need to sign in to do that
Don't have an account?
InterceptTechie
Code:
Id's and Array(0x...) from Perl
Hello,
I am using the SalesForce.pm module to pull down some data using the API. I want to store the SalesForce ID (which is a character field), but when I read the value using the perl API, I get the Id values back as: ARRAY(0x35b8370), etc.
I'm using the example code from another post to hit the api and populate an array to return the data, such as:
my @records = QuerySF("select * from Opportunity"); foreach my $rec (@records) { print "$rec->{Id}"; } sub QuerySF { my $soql = shift; my $lim = '2000'; my $q = $sf->query( query =>$soql, limit => $lim ); my @trans = $q->valueof('//records'); while ( 'false' eq $q->valueof('//done') ) { # query more $q = $sf->queryMore( queryLocator => $q->valueof('//queryLocator'), limit => $lim ); my @more = $q->valueof('//records'); push @trans, @more; } return @trans; }
any ideas? I'm fairly new to Perl, so perhaps I'm missing something.
thank you!
Anyone have any ideas on this one?
Even with the simple example code, I still have the issue. I know it has to be something in Perl, because if i look at the SOAP response, everything is ok (strangly there are two Id's, so I assume thats where the array is coming from). And if i do a Dumper($result->result), the fields look all good.
strange...
Code:
my @idArray= map {$_} (@{$rec->{Id}});
:-)
my $result = $port->query("select * from opportunity", 20);
foreach my $elem ($result->valueof('//queryResponse/result/records')) {
printf "%s, %s\n", $elem->{Id},$elem->{Name};
This doesn't work for me...
Using the reply two posts up, I was able to create the Id instead of the Array Ref. Below is a sample code snippet that performs this operation.
my %account_hash;
my $objType = "Account";
my $query = "select Id, SiteName__c from Account where MID__c = '192160'";
my $result = $sforce->do_query($query);
foreach my $field (@{$result}) {
$_ = $field->{'Id'};
my @idArray = map{$_}(@{$field->{'Id'}});
print $idArray[0]."\t";
print $field->{'SiteName__c'}."\n";
$account_hash{id} = $idArray[0];
$account_hash{'Account_Indexed_On_Date__c'} = "9/11/2009";
}
print "Found ". scalar @{$result} ." results\n";
$update_result = $sforce->update(('type',$objType),%account_hash);