• venchinn2
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 11
    Replies
Hi,
User-added image
User-added image

here i have crated a vf page and wrote a script but the labels are not hide please let me know?
This was the below code..

<apex:page standardController="opportunity">
<apex:includeScript value="{!$Resource.jquery}"/>

<apex:sectionHeader title="opportunity Edit" subtitle="{!opportunity.name}"/>
<apex:form >
<apex:pageBlock title="opportunity Edit" mode="edit">
  <apex:pageBlockButtons location="top">
   <apex:commandButton value="Save" action="{!save}"/>
   <apex:commandButton value="Save & New" action="{!save}" />
    <apex:commandButton value="Cancel" action="{!cancel}"/>
     </apex:pageBlockButtons>
     <apex:pageBlockButtons location="bottom">
      <apex:commandButton value="Save" action="{!save}"/>
       <apex:commandButton value="Save & New" action="{!save}" />
        <apex:commandButton value="Cancel" action="{!cancel}"/>
        </apex:pageBlockButtons>
         <apex:pageBlockSection title="Opportunity Information" columns="2">
         <apex:inputField value="{!opportunity.Name}" required="true"/>
          <apex:inputField value="{!opportunity.Type}" required="false"/>
          <apex:inputField value="{!opportunity.CloseDate}"/>
          <apex:inputField value="{!opportunity.StageName}"/>
        
            <apex:inputField value="{!opportunity.LeadSource}" required="false"/>
             <apex:inputField value="{!opportunity.AccountId}" required="false"/>
              <apex:inputField value="{!opportunity.IsPrivate}" required="false"/>
               <apex:inputField value="{!opportunity.CampaignId}" required="false"/>
            
                    </apex:pageBlockSection>
                     <apex:pageBlockSection title="Contract Information" columns="1">
                   
                     <apex:inputField value="{!opportunity.Funding_Type__c}" id="type" onchange="fund(this)"/>
                  
                 
                    <apex:inputField value="{!opportunity.X60_Minute_Funding_Amt__c}" html-class="dollor"  required="false" id="id1"/>
                     <apex:inputText value="{!opportunity.X60_Minute_Funding__c}" html-class="percentage" required="false" id="id5"/>
                 
                     <apex:inputText value="{!opportunity.X3_Hour_Funding_Amt__c}" html-class="dollor" required="false" id="id2" />
                     <apex:inputField value="{!opportunity.X3_Hour_Funding_1__c}" html-class="percentage" required="false" id="id6"/>
                  
                                     
                     <apex:inputText value="{!opportunity.Next_Day_Funding__c}" html-class="dollor" required="false" id="id3"/>
                     <apex:inputField value="{!opportunity.Next_Day_Funding_Perc__c}" html-class="percentage" required="false" id="id7"/>
                  
                     <apex:inputText value="{!opportunity.Same_Day_Funding_Amt__c}" html-class="dollor" required="false" id="id4"/>
                     <apex:inputField value="{!opportunity.Same_Day_Funding_1__c}" html-class="percentage" required="false" id="id8"/>
                  
                  
                   
                          </apex:pageBlockSection>
                                 </apex:pageBlock>
                                 </apex:form>
                              
                              
                    <script type="text/javascript">

               function fund(s){
           
                if(s.value =='$'){
                    j$ = jQuery.noConflict();
                    j$(".dollor").show();
                     j$(".percentage").hide();
                }else
                  if(s.value =='%'){
                    j$ = jQuery.noConflict();
                    j$(".dollor").hide();
                    j$(".percentage").show();
                }else{
                    j$ = jQuery.noConflict();
                    j$(".dollor").show();
                    j$(".percentage").show();
                }
 
           }
    
                </script>
 
           </apex:page>

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 i got error please let me know ..


<apex:page>
  <html>
  <head>
    <meta http-equiv="Content-type" content="text/html;charset=UTF-8"/>
    <script type="text/javascript">
      var CLIENT_ID = '107266498774-1d51je6qrp4d7th0b57edidv68ulreih.apps.googleusercontent.com';
      var SCOPES = 'https://www.googleapis.com/auth/drive';

      /**
       * Called when the client library is loaded to start the auth flow.
       */
      function handleClientLoad() {
        window.setTimeout(checkAuth, 1);
      }

      /**
       * Check if the current user has authorized the application.
       */
      function checkAuth() {
        gapi.auth.authorize(
            {'client_id': CLIENT_ID, 'scope': SCOPES, 'immediate': true},
            handleAuthResult);
      }

      /**
       * Called when authorization server replies.
       *
       * @param {Object} authResult Authorization result.
       */
      function handleAuthResult(authResult) {
        var authButton = document.getElementById('authorizeButton');
        var filePicker = document.getElementById('filePicker');
        authButton.style.display = 'none';
        filePicker.style.display = 'none';
        if (authResult && !authResult.error) {
          // Access token has been successfully retrieved, requests can be sent to the API.
          filePicker.style.display = 'block';
          filePicker.onchange = uploadFile;
        } else {
          // No access token could be retrieved, show the button to start the authorization flow.
          authButton.style.display = 'block';
          authButton.onclick = function() {
              gapi.auth.authorize(
                  {'client_id': CLIENT_ID, 'scope': SCOPES, 'immediate': false},
                  handleAuthResult);
          };
        }
      }

      /**
       * Start the file upload.
       *
       * @param {Object} evt Arguments from the file selector.
       */
      function uploadFile(evt) {
        gapi.client.load('drive', 'v2', function() {
          var file = evt.target.files[0];
          insertFile(file);
        });
      }

      /**
       * Insert new file.
       *
       * @param {File} fileData File object to read data from.
       * @param {Function} callback Function to call when the request is complete.
       */
      function insertFile(fileData, callback) {
        const boundary = '-------314159265358979323846';
        const delimiter = "\r\n--" + boundary + "\r\n";
        const close_delim = "\r\n--" + boundary + "--";

        var reader = new FileReader();
        reader.readAsBinaryString(fileData);
        reader.onload = function(e) {
          var contentType = fileData.type || 'application/octet-stream';
          var metadata = {
            'title': fileData.name,
            'mimeType': contentType
          };

          var base64Data = btoa(reader.result);
          var multipartRequestBody =
              delimiter +
              'Content-Type: application/json\r\n\r\n' +
              JSON.stringify(metadata) +
              delimiter +
              'Content-Type: ' + contentType + '\r\n' +
              'Content-Transfer-Encoding: base64\r\n' +
              '\r\n' +
              base64Data +
              close_delim;

          var request = gapi.client.request({
              'path': '/upload/drive/v2/files',
              'method': 'POST',
              'params': {'uploadType': 'multipart'},
              'headers': {
                'Content-Type': 'multipart/mixed; boundary="' + boundary + '"'
              },
              'body': multipartRequestBody});
          if (!callback) {
            callback = function(file) {
              console.log(file)
            };
          }
          request.execute(callback);
        }
      }
    </script>
    <script type="text/javascript" src="https://apis.google.com/js/client.js?onload=handleClientLoad"></script>
  </head>
  <body>
    <!--Add a file picker for the user to start the upload process -->
    <input type="file" id="filePicker" style="display: none" />
    <input type="button" id="authorizeButton" style="display: none" value="Authorize" />
  </body>
</html>
</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,
User-added image
User-added image

here i have crated a vf page and wrote a script but the labels are not hide please let me know?
This was the below code..

<apex:page standardController="opportunity">
<apex:includeScript value="{!$Resource.jquery}"/>

<apex:sectionHeader title="opportunity Edit" subtitle="{!opportunity.name}"/>
<apex:form >
<apex:pageBlock title="opportunity Edit" mode="edit">
  <apex:pageBlockButtons location="top">
   <apex:commandButton value="Save" action="{!save}"/>
   <apex:commandButton value="Save & New" action="{!save}" />
    <apex:commandButton value="Cancel" action="{!cancel}"/>
     </apex:pageBlockButtons>
     <apex:pageBlockButtons location="bottom">
      <apex:commandButton value="Save" action="{!save}"/>
       <apex:commandButton value="Save & New" action="{!save}" />
        <apex:commandButton value="Cancel" action="{!cancel}"/>
        </apex:pageBlockButtons>
         <apex:pageBlockSection title="Opportunity Information" columns="2">
         <apex:inputField value="{!opportunity.Name}" required="true"/>
          <apex:inputField value="{!opportunity.Type}" required="false"/>
          <apex:inputField value="{!opportunity.CloseDate}"/>
          <apex:inputField value="{!opportunity.StageName}"/>
        
            <apex:inputField value="{!opportunity.LeadSource}" required="false"/>
             <apex:inputField value="{!opportunity.AccountId}" required="false"/>
              <apex:inputField value="{!opportunity.IsPrivate}" required="false"/>
               <apex:inputField value="{!opportunity.CampaignId}" required="false"/>
            
                    </apex:pageBlockSection>
                     <apex:pageBlockSection title="Contract Information" columns="1">
                   
                     <apex:inputField value="{!opportunity.Funding_Type__c}" id="type" onchange="fund(this)"/>
                  
                 
                    <apex:inputField value="{!opportunity.X60_Minute_Funding_Amt__c}" html-class="dollor"  required="false" id="id1"/>
                     <apex:inputText value="{!opportunity.X60_Minute_Funding__c}" html-class="percentage" required="false" id="id5"/>
                 
                     <apex:inputText value="{!opportunity.X3_Hour_Funding_Amt__c}" html-class="dollor" required="false" id="id2" />
                     <apex:inputField value="{!opportunity.X3_Hour_Funding_1__c}" html-class="percentage" required="false" id="id6"/>
                  
                                     
                     <apex:inputText value="{!opportunity.Next_Day_Funding__c}" html-class="dollor" required="false" id="id3"/>
                     <apex:inputField value="{!opportunity.Next_Day_Funding_Perc__c}" html-class="percentage" required="false" id="id7"/>
                  
                     <apex:inputText value="{!opportunity.Same_Day_Funding_Amt__c}" html-class="dollor" required="false" id="id4"/>
                     <apex:inputField value="{!opportunity.Same_Day_Funding_1__c}" html-class="percentage" required="false" id="id8"/>
                  
                  
                   
                          </apex:pageBlockSection>
                                 </apex:pageBlock>
                                 </apex:form>
                              
                              
                    <script type="text/javascript">

               function fund(s){
           
                if(s.value =='$'){
                    j$ = jQuery.noConflict();
                    j$(".dollor").show();
                     j$(".percentage").hide();
                }else
                  if(s.value =='%'){
                    j$ = jQuery.noConflict();
                    j$(".dollor").hide();
                    j$(".percentage").show();
                }else{
                    j$ = jQuery.noConflict();
                    j$(".dollor").show();
                    j$(".percentage").show();
                }
 
           }
    
                </script>
 
           </apex:page>

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!