• venchinn2
  • NEWBIE
  • 0 Points
  • Member since 2013

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

Hi ,

I want to create a gmail gadget which will show th salesforce data into that gadget - now i want to authenticate salesforce from google how will i authnticate this? please tell me...

I have created one custom object and  i got this error 

System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Parent]: [Parent]

Error is in expression '{!UploadFile}' in component <apex:commandButton> in page vffileupload

 

 

Class.VFFileUpload.UploadFile: line 26, column 1

-------------------------------------------------------------------------------

 

public class VFFileUpload
{
public Id recId
{ get;set; }

public VFFileUpload(ApexPages.StandardController ctlr)
{
recId = ctlr.getRecord().Id;
}

public string fileName
{ get;set; }

public Blob fileBody
{ get;set; }

public PageReference UploadFile()
{
PageReference pr;
if(fileBody != null && fileName != null)
{
Attachment myAttachment = new Attachment();
myAttachment.Body = fileBody;
myAttachment.Name = fileName;
myAttachment.ParentId = recId;
insert myAttachment;
pr = new PageReference('/' + myAttachment.Id);
pr.setRedirect(true);
return pr;
}
return null;
}
}

 

 

-------------------

 

<apex:page standardController="MyCustomObject__c" extensions="VFFileUpload">
<apex:form>
<apex:pageBlock title="Upload Attachment">
<apex:inputFile style="width:100%" id="fileToUpload" value="{!fileBody}" filename="{!fileName}" />
<apex:commandButton value="Upload Attachment" action="{!UploadFile}"/>
</apex:pageBlock>
</apex:form>
</apex:page>

when i tried this code i got the above error

 

 

public class GoogleDrive
{
private static Http http;
private static HttpRequest httpReq;
private static HttpResponse httpRes;
private static void Initialize()
{
http = new Http ();
httpReq = new HttpRequest();
httpRes = new HttpResponse();
}
public static boolean getTokens(String tokenType)
{
String messageBody='';
Initialize();
httpReq.setMethod('POST');
httpReq.setEndpoint('https://accounts.google.com/o/oauth2/token');
httpReq.setHeader('content-type',
'application/x-www-form-urlencoded');

messageBody =
'client_id='+107266498774.apps.googleusercontent.com+
'&client_secret='+Heda08bh6mJLj6d3k5v3HFc2;

if(tokenType=='ALL')
messageBody = messageBody +
'&code='+4/GT1nC7wEx5nIxR5NLTG84oNOQFvc.ciFUSB7eh3AcXE-sT2ZLcbQhBE8nhQI+
'&redirect_uri='+https://login.salesforce.com/apex/GoogleDrive+
'&grant_type='+'authorization_code';

else if(tokenType=='ACCESS_TOKEN')
messageBody = messageBody +
'&refresh_token='+1/2uIcaI7VPTv3F1KyD7EF_JZHHLQdErXWRYOPZMTJVws+
'&grant_type='+'refresh_token';

httpReq.setHeader('Content-length',
String.valueOf(messageBody.length()));

httpReq.setBody(messageBody);
try
{
httpRes = http.send(httpReq);
parseJSON(httpRes.getBody());
return true;
}
catch(Exception ex)
{
System.debug('Class: GoogleDrive',
'Method: getTokens',
ex.getMessage());
return false;
}
}
private static void parseJSON(String jsonText)
{
JSONParser parser = null;
parser = JSON.createParser(jsonText);
while (parser.nextToken() != null)
{
if(parser.getText()=='access_token')
{
parser.nextToken();
<Save as Access Token into Key Safe>
}
if(parser.getText()=='refresh_token')
{
parser.nextToken();
<Save as Refresh Token into Key Safe>
}
}
}
}

 

 

Please let me know what is the problem?

Hi, my question is:
"is possible upload file, pdf or word, from my web application made in Salesforce(using Apex and Visualforce) to my drive in Google?"
I have downloaded the integration toolkit for Google, i can create file (spreadsheet or document) but i am not be able to upload file.
Anyone know how do this???

Thanks!

Hi,

 

I am building a custom button on the opportunity page which needs to get all the contacts associated with that opportunity. And then I need to get the contact details for this contact. How can I do this? I need to do this using Javascript, as I don't have s-control available on my edition of salesforce.

 

Appreicate your help.

 

Thanks!