• Sathyaincampus
  • NEWBIE
  • 25 Points
  • Member since 2008

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

I would like to make content workspace files available on a force.com site page ( for un-authenticated user). Is this possible ?

 

If the answer is yes, then where and how do I set content workspace permission for un-authenticated user. In the workspace permission menu, I do not see an option to include unauthenticated user for view permission.

I do not want to use cutomer portal or  partner portal for this purpose. Thanks !

  • April 03, 2011
  • Like
  • 0

I have been trying to connect Salesforce and Google API using server to server application.

 

Intent :- To communicate data between Salesforce and Google Spreadsheet which is hosted in Google Sites and using some Google Forms, Google scripts and triggers to update data.

 

So, for doing this I need a server to server application model from Google as it wouldnt require a consent from user while its communicating data. for doing this I need to create a JWT and pass it to Google to get the token and proceed with the next steps.

 

JWT for Google requires a RSA with SHA256 signing of the msg using the private key that google has provided in the certificate when I created the server to server application in Google.

I havent found this info anywhere till now :(

In salesforce, we have a crypto class in which can sign with RSA SHA1 (or) generate digest with SHA256, I tried generating a digest using SHA256 and signing that digest usng RSA and the private key given by google. Even thats not working.

 

Google isnt accepting my assertion values (JWT) and its returning an invalid Grant message.

 

I have seen that Jeff douglas has posted some information about this here :-http://blog.jeffdouglas.com/2010/07/06/using-rsa-sha1-with-salesforce-crypto-class/

But unfortunately he has mentioned about domain model and asking us to upload a certificate to google, which i dont want to do or which is not my scenario.

 

Also Google requires a UT8 base64 URL encoded value at all places as mentioned in this link :-https://developers.google.com/accounts/docs/OAuth2ServiceAccount#libraries But salesforce has a separate URL encoding and a separate base64encoding method available in the EncodingUtil class.

 

I have a C# dotnet application which is generating the same value and its able to hit Google and get the value properly. But uses the certificate file and gets the privatekey directly. I used openssl to retrieve the privatekey from the .p12 certificate file provided by Google and have pasted it in my code. I am sure there is some problem in the signing part, because when I compare the values generated by my .NET application and Salesforce Apex code, its returning correct values, but when it comes to the signature part, the length is also same for the returned data (signature) from both .NET and SF but Google returns an invalid grant while calling from SF but returns a bearer token when I call it from my .NET application.

 

public class TestRestAPICall
{
    public class JWTClaimSet
    {
       public string iss {get;set;}
       public string scope {get;set;}
       public string aud {get;set;}
       public Long exp {get;set;}
       public Long iat {get;set;}
       //public string prn {get;set;}
    }

//@future (callout=true)
public static void LoginToGoogle()
{
    //Set your username and password here        
    String clientId = '851234545868.apps.googleusercontent.com';

    //Construct HTTP request and response
    Http http = new Http();
    HttpRequest req = new HttpRequest();
    HttpResponse res = new HttpResponse();


    String JWTHeader =  '{"typ":"JWT","alg":"RS256"}';
    //String Base64EncodedJWTHeader = 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9'; //To encode later using code

    //Taken from .net application
// Since the information is going to be same, I have encoded it already in .NET and using it here
    String Base64EncodedJWTHeader = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9';
// Salesforce returns time in milliseconds, so we are dividing it by 1000 to set the seconds value instead of milliseconds value
    Long expires_at = math.roundToLong(DateTime.now().addMinutes(40).getTime() / 1000);
    Long issued_at = math.roundToLong(DateTime.now().addSeconds(-2).getTime() / 1000);
    //Long issued_at = 1372276504;
    //Long Expires_at = 1372279804;

    JWTClaimSet JWT = new JWTClaimSet();
    //JWT.prn = username;
    JWT.iss = '851234545868@developer.gserviceaccount.com';
    JWT.scope = 'https://www.googleapis.com/auth/drive.file';
    JWT.aud = 'https://accounts.google.com/o/oauth2/token';
    JWT.iat = issued_at;
    JWT.exp = expires_at;

    String strJWTJSON = JSON.Serialize(JWT);
    system.debug('Unencoded claimset::'+strJWTJSON);


    Blob ClaimsetBlob = Blob.valueOf(strJWTJSON);
    String Base64EncodedClaimset = EncodingUtil.base64Encode(ClaimsetBlob);
    //Base64EncodedClaimset = PerformPostBase64Encode(Base64EncodedClaimset);
    system.debug('Base64 Encoded Claimset::'+Base64EncodedClaimset);

    // constructing the base64 encoded string to sign it
    string Base64EncodedString = Base64EncodedJWTHeader + '.' + Base64EncodedClaimset;


    // Steps to sign the base64Encoded string
    String algorithmName = 'RSA';
    String key = 'MIICXAIBAAKBgQCi16h+5TeQU5Fo0DlR6+YmrzYXZ7DLxz+dBEnB8Hj0gznqlz8p7nQ7I4AV/SfiJQ6JbU16sKS5IW7Hob5ieW1DfwxYZeCSBPbEkt7eASrI8xqGU5RVewaQivY3vO+avgSSUT+ZU243XsDvZJQlkE3e46FhBvFedDQvuk2iEfgdxQIDAQABAoGAFaO882f4c0h3qUsKYvWLNxbPhFq2Js5KiM4aEximqi+KEb+ZmDPk5Dr6eXGTzDyKav7IbgZtTWDA/OxkhWeHelsMB9LqBq50L6hLHTK4hHecPrT3oN4GviUXh5y5Vt479A1TopjLKdt7V4AnAs0HEWJzar/euUa+T9eODPWPFP0CQQDWQeK2cqzWSVHUpkufp7a0Sc2RvfcIpOf8kRFBLnKiFGr7BscLz6qsaG1M8TyUNMrCquwLSNSDMvPjl6sCjgRPAkEAwpFx8+lspjN0yV5M5XHPmnoddTHwV/8QHoccMBBq0ZMFs2m1E/rFhwMHRBiFN6flbze8src7YnOmmtYqsGizqwJAfqoEtYel1ikST3zgSEqGIJ9hAEAlwt56pz27zaT/8AHSHQUstzbV14cE1u/muFddZyhU03cC62078djAKIp80QJAKMMT3ofOrVsmYnGRJpibZ7+hoEXgFm9nTx37N86YsmNc1GOW/iKRc2GdChUhA7H3DT/eForwtAWKp/Gqa97jlQJBAKjKOIKvdYS9fTpCzs1nUHg9rvVartRR5xxwLH57bBincuSJSBGjwd1FInAh2tgiUGPWGPsplShP87wao9+n9VQ=';
    Blob privateKey = EncodingUtil.base64Decode(key);

    Blob input = Blob.valueOf(Base64EncodedString);
    //Blob SHA256InputBlob = Crypto.generateDigest('SHA-256',input);

    Blob Blobsign = Crypto.sign(algorithmName, input , privateKey);


    // The following line is just for debugging and viewing the blob data in signature as string and its not used anywhere
    String signature = EncodingUtil.urlEncode(EncodingUtil.convertToHex(Blobsign),'UTF-8');

    system.debug('Unencoded signature ::'+signature);
    String base64EncodedSignature = EncodingUtil.base64Encode(Blobsign); 
    //base64EncodedSignature = PerformPostBase64Encode(base64EncodedSignature);
    system.debug('Base 64 encoded signature ::'+base64EncodedSignature );

    system.debug('Encoded assertion : ' + Base64EncodedString+'.'+base64EncodedSignature);

    string URLEncodedUTF8GrantType = encodingUtil.urlEncode('urn:ietf:params:oauth:grant-type:jwt-bearer','UTF-8');
    string URLEncodedUTF8Assertion = encodingUtil.urlEncode(Base64EncodedString+'.'+base64EncodedSignature,'UTF-8');        

    system.debug('URLEncodedUTF8GrantType : ' + URLEncodedUTF8GrantType);
    system.debug('URLEncodedUTF8Assertion : ' + URLEncodedUTF8Assertion);

    //Making the call out
    req.setEndpoint('https://accounts.google.com/o/oauth2/token');
    req.setMethod('POST');
    //req.setHeader('Content-Length', '-1');
    req.setHeader('Content-Type','application/x-www-form-urlencoded');
    //req.setHeader('grant_type',URLEncodedUTF8GrantType);
    //req.setHeader('assertion',URLEncodedUTF8Assertion);
    req.setBody('grant_type='+URLEncodedUTF8GrantType+'&assertion='+URLEncodedUTF8Assertion);
    res = http.send(req);
    system.debug('Response : '+res.getBody());
}

 public static String PerformPostBase64Encode(String s)
 {
    s = s.Replace('+', '-');
    s = s.Replace('/', '_');
    s = s.Split('=')[0]; // Remove any trailing '='s
    return s;
 }
}

 

 

I have also posted my problem at stackexchange, it would be great if anyone could help me out :-

 

http://salesforce.stackexchange.com/questions/13301/connect-apex-and-google-api-using-jwt-to-retrieve-oauth-2-0-token

Guys,

 

    I have posted my issue here..

http://salesforce.stackexchange.com/questions/511/calling-an-actionfunction-reloads-the-page-despite-giving-rerender-attribute-and

 

can someone please help??

 

Have also pasted the same below for quick access.. but not formatted properly as i have copied and pasted from stackexchange. sorry for that..

Access to entity 'StaticResource' denied. How to give access to partner portal profile? :-

 

 

 

 

calling an actionfunction reloads the page despite giving 1.return false from the place where we call 2. rerender="emptydiv" and says insufficient privileges in Sites (authenticated using partner portal).. but if we refresh the page again or reload by pressing enter in the url again, its not throwing that insufficient privileges error..

any ideas or suggestions to solve this problem would be much appreciated...

updated :- I have given access to all the objects and classes. when I try to preview as admin, I got this error. "Access to entity 'StaticResource' denied" Am accessing this in my code. Not sure how to give access to this StaticResource Object for my Partner Portal User Profile.I dont find this object in the profile. Can you please help?

List resourceList = [SELECT Name, NamespacePrefix, SystemModStamp FROM StaticResource WHERE Name = 'MyStyles'];

This is my scenario :- I have a JQGrid. inside that I have a column in which I have a link (a tag).
Am populating data for the JQGrid from from the controller.
The method is hit as I have specified the URL parameter of JQGrid.

So whenever the pageload or any operation in the grid happens and tries to reload the grid, it hits the url and based on the JSON returned, the grid is populated.

Inside the grid, I have to show some images. for doing that am getting the images through the above code and assigning it to a property for displaying in the grid. The GetresourceURL function in the below code pulls the data from the list fetched in above code and checks what type of image is needed and does some manipulations and gives the actual resource url for the image.

I have just pasted the smaller version of the GetResourceURL code for your easy understanding.

Actually the thing here is, when i click on the application link it should log an entry in a tracking object (just to note that the user has clicked the link and its used for reporting purposes later). for this reason am doing an onclick javascript and from this am calling an actionfunction which does the job of logging in to necessary object and opens the target link in a new tab.

actually it logs the data and it tries to reload the page. not sure why it does that.. the same page is not reloaded.

if i run the visualforce page as a system administrator, but when viewing from sites url as an external customer this "Insufficient privileges" error is thrown.

So, first time the page is getting loaded. When i click on this link the page is performing actionfunction when viewed from sites, and reloading the page (which shouldnt actually reload). If it is an insufficient access for static resource how is it able to access for the first time load? 

asset.ApplicationNumber = (currentAsset.Country_c == 'US' && currentAsset.URL_c != null && !currentAsset.URL_c.contains('patentnumber'))?string.format('{1}',new String[] {currentAsset.URL_c, currentAsset.ApplicationNumber_c,'\''+currentAsset.ApplicationNumber_c+'\'','\''+currentAsset.URL_c+'\'','\'' + currentAsset.Id +'\'','\'' + CompanyID +'\''}):currentAsset.ApplicationNumber_c;

currentDoc.DocumentTitle_c= string.format('{3}',new String[] {'\'' + currentDoc.Id + '\'','\'View\'','\''+UserType+'\'', (GetResourceURL(resourceList, currentDoc.FileType)!='')?(' '+ currentDoc.DocumentTitle_c):currentDoc.DocumentTitle_c,'\'' + docInfo.DocTitleWithoutImage +'\'','\'' + CompanyID +'\'','\'' + currentDoc.FileName_c +'\'','\'' + BaseURL +'\''});

GetResourceURL()

{

return ((Site.getPrefix() != null) ? Site.getCurrentSiteUrl() : '') + '/resource/' + resourceLst[0].SystemModStamp.getTime() + '/' + (namespace != null && namespace != '' ? namespace + '__' : '') + 'MyStyles' + '/CSS/Images/' + imageName;

}

When I use chrome developer tools to see whats happening. I am seeing an internal server error 500 :-
This error is thrown :-

this._request.send(this._query.getQueryString());if(this._timeout>0){this._timeoutID=window.setTimeout(function(){LOG.warn("request stopped due to timeout");if(!_this._aborted){if(typeof(A4J.AJAX.onAbort)=="function"){A4J.AJAX.onAbort(_this);}}

Images below :- (says I dont have 10 reputation and not allowing me to post images. but it gave this url. when i uploaded. please check if you are able to see this image or else let me know i will post it somewhere else and will give the url.)

http://i.stack.imgur.com/23llj.png

http://i.stack.imgur.com/UGJa8.png

Regards
Sathya

I have a problem. am not able to login to my premier training and also to community.salesforce.com using my userid. it says the following error message. 

 

 

The salesforce.com servers are temporarily unable to respond to your request. We apologize for the inconvenience. Thank you for your patience, and please try again in a few moments.

 

and am not even able to edit my user detail from Manage Users. (using my login and also using some other admin login) am getting the following error. can someone help me please???

 

Data Not Available
The data you were trying to access could not be found. It may be due to another user deleting the data or a system error. If you know the data is not deleted but cannot access it, please look at oursupport page. 

Click here to return to the previous page.

Guys, Any idea on date format cast function for SOQL? similar to convert(varchar,getdate(),106) in sql

Am trying to format the grid in asp.net using the output but since the output is returned as string it is difficult for me to format the date based on the culture info. and all my controls are created dynamically in the page which are queried using the partner wsdl. So I desperately need this. can someone help on this pls?

 

regards

Sathya

framing the soql from  the listview columns based on metadata fetch and querying it using the partner wsdl

 

 i queried an opportunities list view.. for example all opportunities it lists me columns like CORE.USER.ALIAS, FULL_Name, etc. How do i frame an SOQL by getting these column names.. 

for ex: am expecting the output like select core.user.alias,full_name,opportunity.name,account.name from opportunity

i should be able to query with the columns nodes available in the xml retrieved from the metadata call..

any ideas????

regards
sathya

 i need a current user filter in the view list that is being displayed in the top of every tab in SF.. for ex :- i have a recruiting app.. and each recruiter has their own login.. if they login to the system they should be able to see the positions only they are assigned to.. the information of which will be stored in the Recruiter field (not Owner) under position record. they are requesting that if they choose a view they should be able to see only that.. as per my understanding...there is no option like that in SF.. any ideas? similar to my positions which will be useful only for owner fields...

Hi frenz,

 

    I have a scenario like i have to show the same listbox in my aspx page as it appears in salesforce under each tab which shows the list view (Ex: All,My Opportunities,Closing This month, etc.) - We use to click new and create new view and set the restrictions for the users correct? i need to query the same using some SOQL and api thru the wsdl and display the same views list and if the user selects that i need to show only those filtered records which has been set in that view and also only the fields specified in that view needs to be displayed in a grid format in my aspx page using c#.

 

I was searching the community and got some info like filterlistId i dont know whats that.. but that too is for visualforce it seems?

Can anyone help me whats the method to query the list views. is it possible? (similar to describeLayout call)

 

Eagerly awaiting reply!!!

Regards

Sathya

 

Hey friends,

 

Not able to delete feed tracked changes.

My development sandbox is just 10 MB

but due to some programmatic upload of Contacts and Accounts to the sandbox

back and forth, since the chatter was enabled it has generated around some 42,351 feed tracked changes

where as my contact records count is just 476 and my account records count is also just 172

which has totally occupied only some 1 MB exactly,

where as these 42,351 feed tracked changes have occupied 10.3 MB space.

Sicne my sandbox is only 10 MB size, whenever i try to create even a test record for the custom object that i have created am not able to do this because now the total storage is : 11.6 MB and am getting this error :-

 

Data Storage Limits Exceeded, Additional Data Creation Not Allowed!

Your company currently has exceeded its data storage limits including an extra overflow buffer. Per our terms and conditions, we cannot permit additional data creation within our system until your company first reduces its current data storage. Please contact your company's salesforce.com administrator to resolve this. We apologize for any inconvenience this may cause.

 

Tried all possibilities.

I tried deleting data from all feed related objects through data loader (after exporting).

Also have disabled chatter, waited for some days, enabled it back and deleted feeds. Nothing worked out.

 

Can some body help?

 

Regards

Sathya

 

 

when I try to add this FORCE.COM IDE in my Eclipse I get an error like above :

Update operation has failed
  Error retrieving "plugins/com.salesforce.ide.api_14.0.2.200812101436.jar". Server returned HTTP response code: "403 Forbidden" for URL: http://www.adnsandbox.com/tools/ide/install/plugins/com.salesforce.ide.api_14.0.2.200812101436.jar.

Even I am not able to access the URL mentioned above through browser it says URL forbidden.

Am Not able to Install FORCE.COM IDE

I have been trying to connect Salesforce and Google API using server to server application.

 

Intent :- To communicate data between Salesforce and Google Spreadsheet which is hosted in Google Sites and using some Google Forms, Google scripts and triggers to update data.

 

So, for doing this I need a server to server application model from Google as it wouldnt require a consent from user while its communicating data. for doing this I need to create a JWT and pass it to Google to get the token and proceed with the next steps.

 

JWT for Google requires a RSA with SHA256 signing of the msg using the private key that google has provided in the certificate when I created the server to server application in Google.

I havent found this info anywhere till now :(

In salesforce, we have a crypto class in which can sign with RSA SHA1 (or) generate digest with SHA256, I tried generating a digest using SHA256 and signing that digest usng RSA and the private key given by google. Even thats not working.

 

Google isnt accepting my assertion values (JWT) and its returning an invalid Grant message.

 

I have seen that Jeff douglas has posted some information about this here :-http://blog.jeffdouglas.com/2010/07/06/using-rsa-sha1-with-salesforce-crypto-class/

But unfortunately he has mentioned about domain model and asking us to upload a certificate to google, which i dont want to do or which is not my scenario.

 

Also Google requires a UT8 base64 URL encoded value at all places as mentioned in this link :-https://developers.google.com/accounts/docs/OAuth2ServiceAccount#libraries But salesforce has a separate URL encoding and a separate base64encoding method available in the EncodingUtil class.

 

I have a C# dotnet application which is generating the same value and its able to hit Google and get the value properly. But uses the certificate file and gets the privatekey directly. I used openssl to retrieve the privatekey from the .p12 certificate file provided by Google and have pasted it in my code. I am sure there is some problem in the signing part, because when I compare the values generated by my .NET application and Salesforce Apex code, its returning correct values, but when it comes to the signature part, the length is also same for the returned data (signature) from both .NET and SF but Google returns an invalid grant while calling from SF but returns a bearer token when I call it from my .NET application.

 

public class TestRestAPICall
{
    public class JWTClaimSet
    {
       public string iss {get;set;}
       public string scope {get;set;}
       public string aud {get;set;}
       public Long exp {get;set;}
       public Long iat {get;set;}
       //public string prn {get;set;}
    }

//@future (callout=true)
public static void LoginToGoogle()
{
    //Set your username and password here        
    String clientId = '851234545868.apps.googleusercontent.com';

    //Construct HTTP request and response
    Http http = new Http();
    HttpRequest req = new HttpRequest();
    HttpResponse res = new HttpResponse();


    String JWTHeader =  '{"typ":"JWT","alg":"RS256"}';
    //String Base64EncodedJWTHeader = 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9'; //To encode later using code

    //Taken from .net application
// Since the information is going to be same, I have encoded it already in .NET and using it here
    String Base64EncodedJWTHeader = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9';
// Salesforce returns time in milliseconds, so we are dividing it by 1000 to set the seconds value instead of milliseconds value
    Long expires_at = math.roundToLong(DateTime.now().addMinutes(40).getTime() / 1000);
    Long issued_at = math.roundToLong(DateTime.now().addSeconds(-2).getTime() / 1000);
    //Long issued_at = 1372276504;
    //Long Expires_at = 1372279804;

    JWTClaimSet JWT = new JWTClaimSet();
    //JWT.prn = username;
    JWT.iss = '851234545868@developer.gserviceaccount.com';
    JWT.scope = 'https://www.googleapis.com/auth/drive.file';
    JWT.aud = 'https://accounts.google.com/o/oauth2/token';
    JWT.iat = issued_at;
    JWT.exp = expires_at;

    String strJWTJSON = JSON.Serialize(JWT);
    system.debug('Unencoded claimset::'+strJWTJSON);


    Blob ClaimsetBlob = Blob.valueOf(strJWTJSON);
    String Base64EncodedClaimset = EncodingUtil.base64Encode(ClaimsetBlob);
    //Base64EncodedClaimset = PerformPostBase64Encode(Base64EncodedClaimset);
    system.debug('Base64 Encoded Claimset::'+Base64EncodedClaimset);

    // constructing the base64 encoded string to sign it
    string Base64EncodedString = Base64EncodedJWTHeader + '.' + Base64EncodedClaimset;


    // Steps to sign the base64Encoded string
    String algorithmName = 'RSA';
    String key = 'MIICXAIBAAKBgQCi16h+5TeQU5Fo0DlR6+YmrzYXZ7DLxz+dBEnB8Hj0gznqlz8p7nQ7I4AV/SfiJQ6JbU16sKS5IW7Hob5ieW1DfwxYZeCSBPbEkt7eASrI8xqGU5RVewaQivY3vO+avgSSUT+ZU243XsDvZJQlkE3e46FhBvFedDQvuk2iEfgdxQIDAQABAoGAFaO882f4c0h3qUsKYvWLNxbPhFq2Js5KiM4aEximqi+KEb+ZmDPk5Dr6eXGTzDyKav7IbgZtTWDA/OxkhWeHelsMB9LqBq50L6hLHTK4hHecPrT3oN4GviUXh5y5Vt479A1TopjLKdt7V4AnAs0HEWJzar/euUa+T9eODPWPFP0CQQDWQeK2cqzWSVHUpkufp7a0Sc2RvfcIpOf8kRFBLnKiFGr7BscLz6qsaG1M8TyUNMrCquwLSNSDMvPjl6sCjgRPAkEAwpFx8+lspjN0yV5M5XHPmnoddTHwV/8QHoccMBBq0ZMFs2m1E/rFhwMHRBiFN6flbze8src7YnOmmtYqsGizqwJAfqoEtYel1ikST3zgSEqGIJ9hAEAlwt56pz27zaT/8AHSHQUstzbV14cE1u/muFddZyhU03cC62078djAKIp80QJAKMMT3ofOrVsmYnGRJpibZ7+hoEXgFm9nTx37N86YsmNc1GOW/iKRc2GdChUhA7H3DT/eForwtAWKp/Gqa97jlQJBAKjKOIKvdYS9fTpCzs1nUHg9rvVartRR5xxwLH57bBincuSJSBGjwd1FInAh2tgiUGPWGPsplShP87wao9+n9VQ=';
    Blob privateKey = EncodingUtil.base64Decode(key);

    Blob input = Blob.valueOf(Base64EncodedString);
    //Blob SHA256InputBlob = Crypto.generateDigest('SHA-256',input);

    Blob Blobsign = Crypto.sign(algorithmName, input , privateKey);


    // The following line is just for debugging and viewing the blob data in signature as string and its not used anywhere
    String signature = EncodingUtil.urlEncode(EncodingUtil.convertToHex(Blobsign),'UTF-8');

    system.debug('Unencoded signature ::'+signature);
    String base64EncodedSignature = EncodingUtil.base64Encode(Blobsign); 
    //base64EncodedSignature = PerformPostBase64Encode(base64EncodedSignature);
    system.debug('Base 64 encoded signature ::'+base64EncodedSignature );

    system.debug('Encoded assertion : ' + Base64EncodedString+'.'+base64EncodedSignature);

    string URLEncodedUTF8GrantType = encodingUtil.urlEncode('urn:ietf:params:oauth:grant-type:jwt-bearer','UTF-8');
    string URLEncodedUTF8Assertion = encodingUtil.urlEncode(Base64EncodedString+'.'+base64EncodedSignature,'UTF-8');        

    system.debug('URLEncodedUTF8GrantType : ' + URLEncodedUTF8GrantType);
    system.debug('URLEncodedUTF8Assertion : ' + URLEncodedUTF8Assertion);

    //Making the call out
    req.setEndpoint('https://accounts.google.com/o/oauth2/token');
    req.setMethod('POST');
    //req.setHeader('Content-Length', '-1');
    req.setHeader('Content-Type','application/x-www-form-urlencoded');
    //req.setHeader('grant_type',URLEncodedUTF8GrantType);
    //req.setHeader('assertion',URLEncodedUTF8Assertion);
    req.setBody('grant_type='+URLEncodedUTF8GrantType+'&assertion='+URLEncodedUTF8Assertion);
    res = http.send(req);
    system.debug('Response : '+res.getBody());
}

 public static String PerformPostBase64Encode(String s)
 {
    s = s.Replace('+', '-');
    s = s.Replace('/', '_');
    s = s.Split('=')[0]; // Remove any trailing '='s
    return s;
 }
}

 

 

I have also posted my problem at stackexchange, it would be great if anyone could help me out :-

 

http://salesforce.stackexchange.com/questions/13301/connect-apex-and-google-api-using-jwt-to-retrieve-oauth-2-0-token

Hello Everyone,

 

I am using export to excel functionality in my application. It is working fine if list contains less than 1000 records and not working if list is having more than 1000. 

 

When I have done R&D, I found that we can store more than 1000 records in List but if we are going to use it in VF page or DataTable of VF page it gives me exception that 'Collection size 1,007 exceeds maximum size of 1,000'.

 

We can use pagination in this functionality, but it is Separating excel sheet for each page, Which is not a client requirement. Client wants all records in a single excel sheet.

 

So Please suggest me a solution.

 

Regards,

Ashes

  • June 04, 2012
  • Like
  • 0

I'm trying to find a solution that allows me to access sharepoint document libraries from within Salesforce.com. I don't want to replicate any documents into salesforce, they must stay physically located on my sharepoint library but I want to be able to access them from salesforce.com

 

Does anybody here know how I can do this?

I have been searching for a solution to this without success. I can't find a way to implement pagination with more than 10000 records. I've been using StandardSetController but this don't works with more than 10000 records. I've been looking into the batchable interface but not quite sure how to implement this.


Just to be sure, is there a way that I can process more than 10000 records in a StandardSetController ?


Is there other way I can implement a pagination in where my custom object have more than 10000 records. (probably more than 50000 actually)Thanks.Joaquin

 

Has anyone got validation with JQuery working on drop down lists on a visualforce page, as I currently can only validate input fields, although my code works fine on a normal HTML page. I've added the JQuery noConflict function and stripped out any colons in the id name of the form etc... Anyone has any joy sure let me know, thanks:

 

<apex:page sidebar="false" showheader="false" standardstylesheets="false">

 <apex:includeScript value="{!URLFOR($Resource.JQuery2, 'jquery.js')}"/>
 <apex:includeScript value="{!URLFOR($Resource.JQuery2, 'jquery.validate.js')}"/>
 <apex:includeScript value="{!URLFOR($Resource.JQuery2, 'jquery.maskedinput-1.0.js')}"/>
 <apex:includeScript value="{!URLFOR($Resource.JQuery2, 'ui.core.js')}"/>
 <apex:includeScript value="{!URLFOR($Resource.JQuery2, 'ui.accordion.js')}"/>

<script type="text/javascript">
 var j$=jQuery.noConflict();
 
j$(document).ready(function(){

    function jq(myid) {
          return '#' + myid.replace(/(:|\.)/g,'\\\\$1');
       }
       
    var f = '{!$Component.cmaForm}';

    j$("#recordClientPhone").mask("(999) 999-9999");
    j$("#recordClientPhoneAlt").mask("(999) 999-9999");
    j$("#recordClientZip").mask("99999");
    j$("#recordPropertyZip").mask("99999");  
    j$("#recordPurchaseZip").mask("99999");  

    // add * to required field labels
    j$('label.required').append('&nbsp;<strong>*</strong>&nbsp;');

    // accordion functions
    var accordion = j$("#stepForm").accordion();
    var current = 0;
    
    j$.validator.addMethod("pageRequired", function(value, element) {
        var j$element = j$(element)
        function match(index) {
            return current == index && j$(element).parents("#sf" + (index + 1)).length;
        }
        if (match(0) || match(1) || match(2)) {
            return !this.optional(element);
        }
        return "dependency-mismatch";
    }, j$.validator.messages.required)

    
    var v = j$(jq(f)).validate({
        errorClass: "warning",
        onkeyup: false,
        onblur: false,
        submitHandler: function() {
            alert("Submitted, thanks!");
        }
    });
    
    // back buttons do not need to run validation
    j$("#sf2 .prevbutton").click(function(){
        accordion.accordion("activate", 0);
        current = 0;
    });
    j$("#sf3 .prevbutton").click(function(){
        accordion.accordion("activate", 1);
        current = 1;
    });
    // these buttons all run the validation, overridden by specific targets above
    j$(".open2").click(function() {
      if (v.form()) {
        accordion.accordion("activate", 2);
        current = 2;
      }
    });
    j$(".open1").click(function() {
      if (v.form()) {
        accordion.accordion("activate", 1);
        current = 1;
      }
    });
    j$(".open0").click(function() {
      if (v.form()) {
        accordion.accordion("activate", 0);
        current = 0;
      }
    });
 
});
</script>

 <apex:stylesheet value="{!URLFOR($Resource.JQuery2, 'style.css')}"/>
 <apex:stylesheet value="{!$Resource.InsuranceCSS}"/>
 <style type="text/css">
.defaultTableColor {
    background-color: white;
}
.tableRollOverEffect1 {
    background-color: #FAF0E6;
    color: #FFF;
}
.tableRollOverEffect2 {
    background-color: #FAF0E6;
    color: #FFF;
}
.tableRowClickEffect1 {
    background-color: #fe0012;
    color: #FFFFFF;
}
.tableRowClickEffect2 {
    background-color: #00F;
    color: #FFF;
}
</style>


<apex:form title="cmaForm" id="cmaForm" >

I would like to make content workspace files available on a force.com site page ( for un-authenticated user). Is this possible ?

 

If the answer is yes, then where and how do I set content workspace permission for un-authenticated user. In the workspace permission menu, I do not see an option to include unauthenticated user for view permission.

I do not want to use cutomer portal or  partner portal for this purpose. Thanks !

  • April 03, 2011
  • Like
  • 0

Guys, Any idea on date format cast function for SOQL? similar to convert(varchar,getdate(),106) in sql

Am trying to format the grid in asp.net using the output but since the output is returned as string it is difficult for me to format the date based on the culture info. and all my controls are created dynamically in the page which are queried using the partner wsdl. So I desperately need this. can someone help on this pls?

 

regards

Sathya

framing the soql from  the listview columns based on metadata fetch and querying it using the partner wsdl

 

 i queried an opportunities list view.. for example all opportunities it lists me columns like CORE.USER.ALIAS, FULL_Name, etc. How do i frame an SOQL by getting these column names.. 

for ex: am expecting the output like select core.user.alias,full_name,opportunity.name,account.name from opportunity

i should be able to query with the columns nodes available in the xml retrieved from the metadata call..

any ideas????

regards
sathya

 i need a current user filter in the view list that is being displayed in the top of every tab in SF.. for ex :- i have a recruiting app.. and each recruiter has their own login.. if they login to the system they should be able to see the positions only they are assigned to.. the information of which will be stored in the Recruiter field (not Owner) under position record. they are requesting that if they choose a view they should be able to see only that.. as per my understanding...there is no option like that in SF.. any ideas? similar to my positions which will be useful only for owner fields...

is there a way to map between the field name in the report meta data  to salesforce objects?

 

I'm using the Metadata Api to retrive metadata about a report

the result is something like this

 

<?xml version="1.0" encoding="UTF-8"?>
<Report xmlns="http://soap.sforce.com/2006/04/metadata">
    <columns>
        <field>SALUTATION</field>
    </columns>
    <columns>
        <field>FIRST_NAME</field>
    </columns>
    <columns>
        <field>LAST_NAME</field>
    </columns>
    <columns>
        <field>TITLE</field>
    </columns>
    <columns>
        <field>ADDRESS2_STREET</field>
    </columns>
    <columns>
        <field>ADDRESS2_CITY</field>
    </columns>
    <columns>
        <field>ADDRESS2_STATE</field>
    </columns>
    <columns>
        <field>ADDRESS2_ZIP</field>
    </columns>
    <columns>
        <field>ADDRESS2_COUNTRY</field>
    </columns>
    <columns>
        <field>PHONE1</field>
    </columns>
    <columns>
        <field>PHONE3</field>
    </columns>
    <columns>
        <field>PHONE2</field>
    </columns>
    <columns>
        <field>EMAIL</field>
    </columns>
    <columns>
        <field>OWNER_FULL_NAME</field>
    </columns>
    <columns>
        <field>ACCOUNT.NAME</field>
    </columns>
    <columns>
        <aggregateTypes>Sum</aggregateTypes>
        <field>SALES</field>
    </columns>
    <columns>
        <field>Account.Active__c</field>
    </columns>
    <filter>
        <criteriaItems>
            <column>SALES</column>
            <operator>greaterThan</operator>
            <value>40000000</value>
        </criteriaItems>
    </filter>
    <format>Tabular</format>
    <name>muly1</name>
    <reportType>ContactList</reportType>
    <scope>my</scope>
    <showDetails>true</showDetails>
    <timeFrameFilter>
        <dateColumn>CREATED_DATE</dateColumn>
        <interval>INTERVAL_CUSTOM</interval>
        <startDate>2008-08-05</startDate>
    </timeFrameFilter>
</Report>

 

what is ContactList?

what is ADDRESS2_STREET?

 

 

  • August 15, 2010
  • Like
  • 0

I have some test code that creates a portal user. The insert fails with the message "portal account owner must have a role".  

 

The owner of the Account and Contact has a Role, so I'm not sure what to do with this message.  

 

Anyone know how this can be fixed?

I have a problem regarding salesforce email under apex area.

The problem is using 'Html Email Templates' with setTargetObjectId method does not set the User Id:

 

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); logger.log('User found: ' + caseR.User__c); mail.setTargetObjectId(caseR.User__c); mail.setTemplateId('00XT0000000iwz7'); Messaging.Sendemailresult[] emailResult = Messaging.sendEmail(new Messaging.Email[] { mail } , false); logger.log('Email Result: ' + emailResult);

 

And the logging result says that TargetObjectId is null. Why?:

 

2/01/2010 09:15: User found: 00520000000pjkYAAQ 12/01/2010 09:15: Email Result: (Messaging.SendEmailResult[getErrors=(Messaging.SendEmailError[getTargetObjectId=null;]);isSuccess=false;])

 

Please help!

 

thanks,

Cristina.

  • January 12, 2010
  • Like
  • 0

Hello Everyone,

 

I'm trying to make some files we uploaded into salesforce crm content downloadable or accessible by another page via Sites. For instance, say, an mp3, either downloaded or requested by mediaplayer on a webpage.

 

According to the docs 'To download a document via the API, you must export the VersionData of the document.'

 

Well... I've tried a couple variations with a visualforce page to retrieve/export the contentversion, but (as expected) no luck.

 

Does anyone have any good ideas on how to do this?

 

Thanks in advance,

e.

I'm trying to use a Report's metadata to create a SOQL query that pulls back the same data that's in the report. I'm stumped on what I assume are calculated fields.

The metadata is (with a couple of irrelevant fields removed for brevity)
<Report xmlns="http://soap.sforce.com/2006/04/metadata">
<columns> <field>SUBJECT</field> </columns>
<columns> <field>CREATED_DATE</field> </columns>
<columns> <field>AGE</field> </columns>
<columns> <field>OPEN</field> </columns>
<columns> <field>CLOSED</field> </columns>

<format>Tabular</format>
<name>Total Cases Created</name>
<params>
<name>units</name>
<value>h</value>
</params>
<reportType>CaseList</reportType>
<scope>user</scope>
<showDetails>true</showDetails>
</Report>


Problem 1: I see reportType is CaseList, and my human brain can make the leap that the "Master" table (not sure if that's the right term) for this report is Case. How can my code know that though?


Problem 2: I use binding.describeSObject() and DescribeSObjectResult.getFields() to get the field names for Case, there is no Age, no Open, and no Closed. There's IsClosed, which my human brain maps to Closed. And I figure Age is calculated from current time minus CreatedDate and Open is calculated from !IsClosed. But when I try to use, e.g. Age in the query, I get

select Subject, CreatedDate, Age, IsClosed, Account.Name from
                             ^
ERROR at Row:1:Column:30
No such column 'Age__c' on entity 'Case'.
If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. 

 I tried Age__c, but of course that didn't work, because apparently "custom" != "calculated".

So...
  1. Is there a way to find out a Report's Master table, programmaticaly?
  2. Is there a way to get the "real" column name--e.g. IsClosed instead of Closed?
  3. Is there a way to get the calculated fields?

Thanks,
Jeff

  • December 10, 2008
  • Like
  • 0