• ChrisDevOz
  • NEWBIE
  • 25 Points
  • Member since 2010

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

Hi All

 

So, I've spent most of the day trying to work through this, but as yet have had no luck.

 

I'm trying to use the Google API, authenticated with OAuth, to pull down a subset of calendar events.

 

I'm using the Salesforce.com OAuth Playground to take care of the heavy lifting, which up til now has worked ok.

 

If I submit the following GET request,

 

https://www.google.com/calendar/feeds/default/private/full?max-results=24&prettyprint=true

 

I have no problem, and I get the appropriate ATOM feed returned.

 

However, If I modify the request to something like,

 

https://www.google.com/calendar/feeds/default/private/full?max-results=24&prettyprint=true&start-min=2011-03-24T23:59:59

 

I get the 401 Unkown Authorization Header response.  It turns out that any query parameter that has a date/time value causes this error!

 

Both queries work fine using the Google OAuth Playground, and the Signature base strings for both the Salesforce.com & Google requests look correct.

 

I am using anonymous consumer key/secret and HMAC-SHA1 signature method.

 

I know it's a long shot, but if anyone else has come across this, or has any suggestions please let me know.

 

Cheers

 

Chris

Hi Thee, was wondering if someone could help me out with a packaging problem I am having...

 

I have created a base application, which has a limited set of functionality.  Additionally i have developed extension package the completed the application.  This is so we can have our application installed in GE/PE orgs, whilst offering a more comprehensive application to DE/UE/EE customers.

 

I have everything setup, packaged, unit tested etc... The install procedure works fine if I install the base package first then the extension, but it someone wants to install the full version straight away the following happens;

 

Package install error

There are problems that prevent this package from being installed.

A required package is missing         
Package "base xxx", Version 1.2 or later must be installed first.

 

Is there a way round this, or will I have to have every customer install both packages?  Would be a shame not to have a Get it Now button on my AppExchange listing because of this!

 

Cheers

 

Chris

 

Hi All

 

Over the last few months I have been teaching myself Apex.  I have some PHP/javascript experience but apart from that this is all pretty new.

 

I had some live use cases that required the creation of a trigger that I managed to write succesfully and deploy to production.  Everything works ok, but have no idea whether my code is best practice.  I have attempted to write them to allow bulk request and written the appropriate test classes, but beyond that I don't know if they are written well.

 

If any one has any comments/suggestions it would be great to get some feedback.  Also there might be people out there who can benefit from the code.

 

Use Case.

 

When an Account is updated in Salesforce, all child opportunities should be updated with a specific value. This value is created from an external id on the account and a text value on the opportunity.

 

 

trigger updateOpportunityids on Account (after update) {
//soql statement creates a list of all opportunities for the trigger Accounts
List<Opportunity> holdopps = [select id, service_id__c, service__c, account.company_id__c from opportunity where Account.ID IN :Trigger.newMap.keySet()];
// loop through holdopps, assigning each record to the o variable
for (Opportunity o :holdopps) {
// if the service id of the o sobject variable = the combination of the service and company id
if (o.Service_id__c != o.Service__c+o.account.company_id__c && o.account.company_id__c != NULL){
// add the serviceid variable to the current o sObject
o.Service_id__c = (o.Service__c+o.account.company_id__c);
}
}
//Update Opportunities using the holdopps array
try {update holdopps; }
//Exception Handling
catch (DmlException e){
}
}

 

 

And the test class

 

 

public with sharing class updateOpportunityidstest {
static testMethod void testserviceid() {
//create holdopps list
List<Opportunity> holdopps = new List<Opportunity>();

//Create new Accounts
Account a = new Account(Name='A Name', company_id__c = 9999);
Account b = new Account(Name='B Name', company_id__c = 10000);
insert a;
insert b;

//Create Opportunity
Opportunity o = new Opportunity (Name='O Name', Service__c='ii', Service_id__c='', AccountId=a.id);
o.StageName = 'Prospecting';
o.CloseDate = Date.newInstance(2010,06,06);
o.ExpectedUsage__c = 5;
o.Nett_Seat_Fee__c = 5;
insert o;

//Create Error Opportunity
Opportunity p = new Opportunity (Name='P Name', Service__c='ii', Service_id__c='', AccountId=a.id);
p.StageName = '';
p.CloseDate = Date.newInstance(2009,01,01);
p.ExpectedUsage__c = 5;
p.Nett_Seat_Fee__c = 5;

//Update Account
Account c = new Account(Name='B Name', company_id__c = 10001, id = a.id);
update c;
Opportunity q = [select name, Service_id__c from Opportunity where id = :o.id];
system.assertEquals(q.Service_id__c, 'ii10001');
}
}

 

 

That's it, look foward to your feedback!

 

Cheers

 

Chris

Hi All

 

So, I've spent most of the day trying to work through this, but as yet have had no luck.

 

I'm trying to use the Google API, authenticated with OAuth, to pull down a subset of calendar events.

 

I'm using the Salesforce.com OAuth Playground to take care of the heavy lifting, which up til now has worked ok.

 

If I submit the following GET request,

 

https://www.google.com/calendar/feeds/default/private/full?max-results=24&prettyprint=true

 

I have no problem, and I get the appropriate ATOM feed returned.

 

However, If I modify the request to something like,

 

https://www.google.com/calendar/feeds/default/private/full?max-results=24&prettyprint=true&start-min=2011-03-24T23:59:59

 

I get the 401 Unkown Authorization Header response.  It turns out that any query parameter that has a date/time value causes this error!

 

Both queries work fine using the Google OAuth Playground, and the Signature base strings for both the Salesforce.com & Google requests look correct.

 

I am using anonymous consumer key/secret and HMAC-SHA1 signature method.

 

I know it's a long shot, but if anyone else has come across this, or has any suggestions please let me know.

 

Cheers

 

Chris

Hi All

 

Over the last few months I have been teaching myself Apex.  I have some PHP/javascript experience but apart from that this is all pretty new.

 

I had some live use cases that required the creation of a trigger that I managed to write succesfully and deploy to production.  Everything works ok, but have no idea whether my code is best practice.  I have attempted to write them to allow bulk request and written the appropriate test classes, but beyond that I don't know if they are written well.

 

If any one has any comments/suggestions it would be great to get some feedback.  Also there might be people out there who can benefit from the code.

 

Use Case.

 

When an Account is updated in Salesforce, all child opportunities should be updated with a specific value. This value is created from an external id on the account and a text value on the opportunity.

 

 

trigger updateOpportunityids on Account (after update) {
//soql statement creates a list of all opportunities for the trigger Accounts
List<Opportunity> holdopps = [select id, service_id__c, service__c, account.company_id__c from opportunity where Account.ID IN :Trigger.newMap.keySet()];
// loop through holdopps, assigning each record to the o variable
for (Opportunity o :holdopps) {
// if the service id of the o sobject variable = the combination of the service and company id
if (o.Service_id__c != o.Service__c+o.account.company_id__c && o.account.company_id__c != NULL){
// add the serviceid variable to the current o sObject
o.Service_id__c = (o.Service__c+o.account.company_id__c);
}
}
//Update Opportunities using the holdopps array
try {update holdopps; }
//Exception Handling
catch (DmlException e){
}
}

 

 

And the test class

 

 

public with sharing class updateOpportunityidstest {
static testMethod void testserviceid() {
//create holdopps list
List<Opportunity> holdopps = new List<Opportunity>();

//Create new Accounts
Account a = new Account(Name='A Name', company_id__c = 9999);
Account b = new Account(Name='B Name', company_id__c = 10000);
insert a;
insert b;

//Create Opportunity
Opportunity o = new Opportunity (Name='O Name', Service__c='ii', Service_id__c='', AccountId=a.id);
o.StageName = 'Prospecting';
o.CloseDate = Date.newInstance(2010,06,06);
o.ExpectedUsage__c = 5;
o.Nett_Seat_Fee__c = 5;
insert o;

//Create Error Opportunity
Opportunity p = new Opportunity (Name='P Name', Service__c='ii', Service_id__c='', AccountId=a.id);
p.StageName = '';
p.CloseDate = Date.newInstance(2009,01,01);
p.ExpectedUsage__c = 5;
p.Nett_Seat_Fee__c = 5;

//Update Account
Account c = new Account(Name='B Name', company_id__c = 10001, id = a.id);
update c;
Opportunity q = [select name, Service_id__c from Opportunity where id = :o.id];
system.assertEquals(q.Service_id__c, 'ii10001');
}
}

 

 

That's it, look foward to your feedback!

 

Cheers

 

Chris