• mike1051
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 14
    Questions
  • 13
    Replies
I am using dropzone multi-upload Drag and Drop upload into salesforce.Its working fine on all browsers except IE.
Also on IE as well its not working in only 1 scenario..when i have reRender on the page..If i remove reRender it works.Please help i am stuck on this for 2 weeks.
Script starts like below.
<script> 
   // j$ = jQuery.noConflict();
        var myChatterDropzone;
    dz_jQuery(function(){
        var recordId;

        // Try to find the Id of the record we are looking at, if any.
        var documentText = dz_jQuery('html').html();
        var tokenStart = documentText.indexOf("ResponseRequestedURL=") ;
        var documentEnd = documentText.substr(tokenStart,documentText.length);
        var tokenEndIndex = documentEnd.indexOf("');");
        //recordId = documentEnd.substr(tokenEndIndex-15,15);
        recordId='{!snagId}';


<apex:form >
 <apex:outputPanel id="test1" rendered="false" >
 <apex:commandButton value="tesr" rendered="false" reRender="none"/>
</apex:form>
If i just remove reRender from above command button it works perfectly. The above command is not linked at all with upload functionality but just removing it from page works for me. :(
 

i want to update data from google sheet to salesforce.I have called API from salesforce to get data from Google sheet to salesforce.
My code is working fine and i am able to get data from Google sheet.
Problem its running every 1 hour and i am getting the data. Is it possible i can hit any url from google sheet when ever the sheet is updated.? webhook or something.?
HI i am trying to use drag and drop for uploading file into content. Below code works for attachment
sfdcurl = '/services/data/v27.0/sobjects/Attachment/';


When i tried to change it Feeditem object it doesn't work.Please tell me if the url is wrong or anything else i am doing wrong.
sfdcurl = '/services/data/v27.0/sobjects/Feeditem/';

<script>

              var curPopupWindow = [];

            var headersData = {}; 
            headersData["Authorization"] = "Bearer {!$Api.Session_ID}";
            sfdcurl = '/services/data/v27.0/sobjects/Feeditem/';
            Dropzone.autoDiscover = false;
            var myDropzone = new Dropzone("div#dropzone-email-dropable", {
                        maxFiles: 25,
                        url: sfdcurl,
                        addRemoveLinks:true,
                        dictCancelUpload:"Cancel Upload",
                        dictCancelUploadConfirmation:"Are You Sure?",
                        dictRemoveFile:"Remove",
                        parallelUploads:2,
                        filesizeBase:1024,
                        maxFilesize:10,
                        //autoProcessQueue:false,
                        //params: {"ParentId" : "{!contentFolderId}","Description" : "{!sessionId}"},
                        params: {"ParentId" : "{!contentFolderId}"},
                        headers: headersData,
                        init: function () {
                            this.on("maxfilesexceeded", function (data) {
                                var res = eval('(' + data.xhr.responseText + ')');

                            });
                            this.on("removedfile", function (file) {
                                console.log(file.uploadId);
                                this.deleteFile(file,this.options.url);
                                //refreshAttachments();
                            });
                            this.on("success", function (file,resp) {
                                file.uploadId = resp.id;
                                //refreshAttachments();

                            });

                        }
                    });
               console.log({!success});            
            </script>


 
Hi i have created a VF page to capture signature uisng this link

Link which i have used

http://corycowgill.blogspot.in/2013/12/capturing-signatures-with-html5-canvas.html

It working fine in individual vf page but when i add tr,td and table it is not working.I just don't know the reason why..Trying to sort this out from last 2 days.Need urgent help in this.

Below is the code

VF page

<apex:includeScript value="/soap/ajax/28.0/connection.js"/>

     <style>
      .container {
       text-align: center;
       font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
       color: cadetblue;
       font-weight: 500;
       font-size: 14px;
      }

      .button {
       font-family: calibri;
       border-radius: 8px;
       background-color: rgb(51, 116, 116);
       height: 36px;
       color: azure;
       font-size: 17px;
       border-width: 0px;
       width: 116px;
      }
     </style>

Javascript


>  <script>
> 
> var canvas;   var context;   var drawingUtil;   var isDrawing = false;
> var accountId = '';   var prevX, prevY, currX, currY = 0;   var
> accountId;
> 
>    function DrawingUtil() {    isDrawing = false;   
> canvas.addEventListener("mousedown", start, false);   
> canvas.addEventListener("mousemove", draw, false);   
> canvas.addEventListener("mouseup", stop, false);   
> canvas.addEventListener("mouseout", stop, false);   
> canvas.addEventListener("touchstart", start, false);   
> canvas.addEventListener("touchmove", draw, false);   
> canvas.addEventListener("touchend", stop, false);    w = canvas.width;
>       h = canvas.height;   }
> 
>    function start(event) {    event.preventDefault();
>        isDrawing = true;    prevX = currX;    prevX = currY;    currX = event.clientX - canvas.offsetLeft;    currY = event.clientY - canvas.offsetTop;
>        context.beginPath();    context.fillStyle = "cadetblue";    context.fillRect(currX, currY, 2, 2);
>             context.closePath();
>       }
> 
>    function draw(event) {    event.preventDefault();    if (isDrawing)
> {
>     prevX = currX;
>              prevY = currY;
>              currX = event.clientX - canvas.offsetLeft;
>              currY = event.clientY - canvas.offsetTop;
>     context.beginPath();
>     context.moveTo(prevX, prevY);
>     context.lineTo(currX, currY);
>     context.strokeStyle = "cadetblue";
>     context.lineWidth = "2";
>     context.stroke();
>     context.closePath();    }   }
> 
>    function stop(event) {    if (isDrawing) {
>     context.stroke();
>     context.closePath();
>     isDrawing = false;    }   }
>      function clearSign() {    context.clearRect(0,0,w,h);   }
> 
>    canvas = document.getElementById("signatureCanvas");
>      context = canvas.getContext("2d");
>      context.strokeStyle = "black";   context.lineWidth = "2";
>      drawingUtil = new DrawingUtil(canvas);
>       alert('hi');
> 
>    function saveSignature() {    var strDataURI = canvas.toDataURL(); 
> strDataURI = strDataURI.replace(/^data:image\/(png|jpg);base64,/, "");
> var accId = location.href.split('=')[1];    accountId = accId;    var
> result = CaptureSignatureController.saveSignature(strDataURI, accId,
> processResult);   }
> 
>    function processResult(result) {    alert(JSON.stringify(result)); 
> window.location.href = '/'+accountId;   }
> 
>   
> 
>   </script>


 <div class="container">
   <h1 class="labelCol vfLabelColTextWrap ">Record Signature:</h1>
   <canvas id="signatureCanvas" height="100px" width="350px" style="border: 3px solid antiquewhite; border-radius: 8px;" ></canvas>
  </div><br/>

Issue

Even if i add normal HTML tags anywhere inside the form i am not able to draw anything. Below is the eg if i add this on the page it stopped working,if i remove it started working again.

I need urgent help in this thanks.

<table width="100%">
          <tr>
            <td width="5%"></td>
             <td width="15%"><apex:outputText >Upload</apex:outputText></td>

          </tr> 
     </table>



I have shown some fields in my component page and i am using that component in my main page..I want to get the list value that i have used in my component class to my main controller class..I tried to extend my component class and tried to access the list but i am getting a null list..

Component

<apex:component controller="objectComController">
 <apex:repeat value="{!objectList}" var="wra" id="theRepeat">
  <apex:inputField value="{!wra.nameField}"></apex:inputField>
 </apex:repeat>




</apex:component>

Component Class

public with sharing abstract class objectComController{
public List<object__c> objectList{get;set;}

public objectComController()
{
    objectList=new List<object__c>();
}

}

I am getting the values in objectList in this component controller.
Main Class where i have used this controller

public with sharing class mainClass extends objectComController{

   public void Save()
   {
       System.debug('============'+objectList);

   }
}

When i am trying to debug the values of the list in my maincontroller the values are coming null.I just need to get my list values from my component class in my main class.

Its very urgent for me.Please help.Thanks in advance.



I have button on Opportunity on click oh which i am opening a VF page window .After opening the URl becomes

https://c.cs16.salesforce.com/apex/VFpage

On Click of save button i am closing the opoup window and refreshing parent window but when i close it it show a javascript popup error after closing the window.It says

A problem with the OnClick JavaScript for this button or link was encountered:

Blocked a frame with origin "https://cs16.salesforce.com" from accessing a cross-origin frame.




I know this error is coming because the URL are different but i dont know how to solve this issue.

Can someone tell me how to solve that issue.Its urgent for me.

I am opening a POPup window..which i am opening a VF page onlclick of a custom button.I Want to close the child window and redirect the parent window to email author page with some parameters/

https://cs16.salesforce.com/_ui/core/email/author/EmailAuthor?doc_id=00Pf0000000x1HuEAI&p3_lkid=006f0000004fKcj


I know how to close the child window but can someone tell me to redirect the parent window

function myClose(){

    self.close();
    window.opener.location.href="/{!$CurrentPage.parameters.Id}";

    //you could also use self.close();   
    }


I would really appreciate.

Thanks
I am trying to send an email using URL hacking and using standard salesforce Email functionality.

I will be coming to this page using Opportunity PDF. Problem is how to show an attachment down below in the attached files of this page.

I did R&D and found that only document can be visible and not attachment.Is there a way i can show the attachment and send that attachment in the email..

If this is not possible.We cannot make the attachment visible.Can i send the attachment using code but only from that standard email author page..?
https://cs16.salesforce.com/_ui/core/email/author/EmailAuthor?doc_id=00Pf0000000x1HuEAI&p3_lkid=006f0000004fKcj

I am opening a pop up VF page as 'render as pdf'.I have created a button Save and on click on save i am closing the pop window and saving PDf to opportunity.

Issue

When i am saving the code when calling the savePdf method without rerender and oncomplete.Its saving the attachment and i am able to open the attachment in opportunity without issue.When i am using either using rerender or oncomplete i am able to save the attachment but it says ".'Failed to load document'"

Its been a week i am stuck please help.

<apex:form>

function myClose(){

    self.close();
    window.opener.location.href="/{!$CurrentPage.parameters.Id}";

    //you could also use self.close();   
    }
<apex:pageBlock mode="maindetail" id="thePb"> 

      <apex:pageBlockButtons >
        <apex:commandButton value="Save to Opportunity" action="{!savePdf}" oncomplete="myClose();"  />

      </apex:pageBlockButtons>
      <apex:pageMessages />

     <iframe height="600px" id="Page" name="InvoicePDF" src="/apex/GenerateQuotePDF?id={!parentId}" width="100%"></iframe>

    </apex:pageBlock>
  </apex:form>


Class

public void savePdf() {

    PageReference pdf = Page.GenerateQuotePDF;
    pdf.getParameters().put('id',parentId);
     pdf.setRedirect(true);
    // create the new attachment
  Attachment attach = new Attachment();

    // the contents of the attachment from the pdf
    Blob body;

        body = pdf.getContent();

    attach.Body = body;
    // add the user entered name
    attach.Name = 'Opportunity'+ '.pdf'; 
    attach.IsPrivate = false;
    // attach the pdf to the account
    attach.ParentId = parentId;
    attach.ContentType = 'application/pdf';
    insert attach;

  }

have created a VF page and used "render as pdf"

<apex:commandButton value="Save to Opportunity" action="{!savePdf}"  />


Its working fine when i am using above line without rerender and oncomplete but when i am adding rerender or oncomplete it is not working.I am able to save the PDF in attachment folder but when i am trying to open its showing "Unable to load document"

Even if i remove oncomplete and use Rerender then also its saving the attachment in Attachment object and when i view ,it is not loading and says "Unable to load document"

<apex:commandButton value="Save to Opportunity" action="{!savePdf}"  oncomplete="myClose();"/>

Javascript Code

function myClose(){

    self.close();
    window.opener.location.href="/{!$CurrentPage.parameters.Id}";
}


Class Code

public void savePdf() {

    PageReference pdf = Page.GenerateQuotePDF;
    pdf.getParameters().put('id',parentId);

    Attachment attach = new Attachment();

    Blob body;
    body = pdf.getContent();
    attach.Body = body;
    attach.Name = 'Opportunity'+ '.pdf'; 
    attach.IsPrivate = false;
    attach.ParentId = parentId;
    attach.ContentType = 'application/pdf';
    insert attach;

  }


Please help..
I have a VF page..I have a button open pop up..on click of that button i am opening a pop up using output panel and css...using the code something like this..

LINK http://www.salesforcegeneral.com/salesforce-modal-dialog-box/

On that pop up i am using autocomplete using VF remoting and a confirm button on that popup..My problem is i am using blur event whenever i type some thing in that autocomplete text box i am selecting a autocomplete record and on onblur event calling a method but the curser remains in that text box.So when i click a confirm button onblur event is again called calling the controller method.

I want the curser to move out of the textbox after onblur event ..?? I need some jquery/javascript code...

close: function(){
      j$(esc('{!autocomplete_textbox}')).blur();
   }
Please help i am stuck with this issue...for 3 days...

Thanks

When i click on this custom button i need to fill a field with the current date and time.But some times its giving me a previous date i.e exactly 1 day prior to current date..i dont know why this is happpening..can some help me out in this..may be there is some issue with javascript...or timezone issue..as its not happening everytime...but sometime..

 

 

var SO = new sforce.SObject("Sales_Order__c");

    function fixTime(time){
       if(time < 10) {time = "0" + time};
       return time;
    }
     function fixDate(date){
      var Month = fixTime(date.getMonth() + 1);
      var Day = fixTime(date.getDate());
      var UTC = date.toUTCString();
      var Time = UTC.substring(UTC.indexOf(':')-2, UTC.indexOf(':')+6);
      var Minutes = fixTime(date.getMinutes());
      var Seconds = fixTime(date.getSeconds());
      return date.getFullYear() + "-" + Month + "-" + Day + "T" + Time;  
    }

    SO.date__c = fixDate(new Date());
updateSO = sforce.connection.update([SO]);

 

I am inserting events and inserting multiple invitees(Lead/Contacts) to event using EventRelation.

EventRealtion er = new EventRelation(EventId = '00UD0000005zijH', 
RelationId = '003D000000Q8adV');
insert er;

problem is when i add invitees using event relation...they dont associate it with lead/contact as event in activity history..they only associate when i put whoid in that event.then it associates automatically...but we can add only 1 whoid to an event..

How can i associate lead with events...can someone provide me a solution for the same..??? any help will be appreciated..

I need to get the associated record. i.e with the radio button.I am using input type radio button for the same.please someone help with the code...

 

 

<apex:column >
    <apex:facet name="header">
        Action
    </apex:facet>
    <input type="radio" name="selection" value="{!m.isSelected}" /> 

 </apex:column>

<apex:column value="{!m.meet.Subject__c}">
    <apex:facet name="header">
        Subject
    </apex:facet>
</apex:column>

 

<apex:commandButton value="Invite To Meeting" action="{!inv}"/>

 wrapper class

public list<meetInviteWrapper> meetwrapperlist{get;set;}
    public class meetInviteWrapper
    {
        public meeting__c meet{get;set;}
        public Boolean isSelected{get;set;}
        public meetInviteWrapper(meeting__c m)
        {
            meet=m;
            isSelected=false;
        }



 public void inv()
    {
    List<meeting__c> mList=new List<meeting__c>();
        for(meetInviteWrapper miw:meetwrapperlist)
        {
            if(miw.isSelected)
            {
                mList.add(miw.meet);
            }

        }
    System.debug('------------------------'+mList);
}

 

 

HI i am trying to use drag and drop for uploading file into content. Below code works for attachment
sfdcurl = '/services/data/v27.0/sobjects/Attachment/';


When i tried to change it Feeditem object it doesn't work.Please tell me if the url is wrong or anything else i am doing wrong.
sfdcurl = '/services/data/v27.0/sobjects/Feeditem/';

<script>

              var curPopupWindow = [];

            var headersData = {}; 
            headersData["Authorization"] = "Bearer {!$Api.Session_ID}";
            sfdcurl = '/services/data/v27.0/sobjects/Feeditem/';
            Dropzone.autoDiscover = false;
            var myDropzone = new Dropzone("div#dropzone-email-dropable", {
                        maxFiles: 25,
                        url: sfdcurl,
                        addRemoveLinks:true,
                        dictCancelUpload:"Cancel Upload",
                        dictCancelUploadConfirmation:"Are You Sure?",
                        dictRemoveFile:"Remove",
                        parallelUploads:2,
                        filesizeBase:1024,
                        maxFilesize:10,
                        //autoProcessQueue:false,
                        //params: {"ParentId" : "{!contentFolderId}","Description" : "{!sessionId}"},
                        params: {"ParentId" : "{!contentFolderId}"},
                        headers: headersData,
                        init: function () {
                            this.on("maxfilesexceeded", function (data) {
                                var res = eval('(' + data.xhr.responseText + ')');

                            });
                            this.on("removedfile", function (file) {
                                console.log(file.uploadId);
                                this.deleteFile(file,this.options.url);
                                //refreshAttachments();
                            });
                            this.on("success", function (file,resp) {
                                file.uploadId = resp.id;
                                //refreshAttachments();

                            });

                        }
                    });
               console.log({!success});            
            </script>


 
Hi i have created a VF page to capture signature uisng this link

Link which i have used

http://corycowgill.blogspot.in/2013/12/capturing-signatures-with-html5-canvas.html

It working fine in individual vf page but when i add tr,td and table it is not working.I just don't know the reason why..Trying to sort this out from last 2 days.Need urgent help in this.

Below is the code

VF page

<apex:includeScript value="/soap/ajax/28.0/connection.js"/>

     <style>
      .container {
       text-align: center;
       font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
       color: cadetblue;
       font-weight: 500;
       font-size: 14px;
      }

      .button {
       font-family: calibri;
       border-radius: 8px;
       background-color: rgb(51, 116, 116);
       height: 36px;
       color: azure;
       font-size: 17px;
       border-width: 0px;
       width: 116px;
      }
     </style>

Javascript


>  <script>
> 
> var canvas;   var context;   var drawingUtil;   var isDrawing = false;
> var accountId = '';   var prevX, prevY, currX, currY = 0;   var
> accountId;
> 
>    function DrawingUtil() {    isDrawing = false;   
> canvas.addEventListener("mousedown", start, false);   
> canvas.addEventListener("mousemove", draw, false);   
> canvas.addEventListener("mouseup", stop, false);   
> canvas.addEventListener("mouseout", stop, false);   
> canvas.addEventListener("touchstart", start, false);   
> canvas.addEventListener("touchmove", draw, false);   
> canvas.addEventListener("touchend", stop, false);    w = canvas.width;
>       h = canvas.height;   }
> 
>    function start(event) {    event.preventDefault();
>        isDrawing = true;    prevX = currX;    prevX = currY;    currX = event.clientX - canvas.offsetLeft;    currY = event.clientY - canvas.offsetTop;
>        context.beginPath();    context.fillStyle = "cadetblue";    context.fillRect(currX, currY, 2, 2);
>             context.closePath();
>       }
> 
>    function draw(event) {    event.preventDefault();    if (isDrawing)
> {
>     prevX = currX;
>              prevY = currY;
>              currX = event.clientX - canvas.offsetLeft;
>              currY = event.clientY - canvas.offsetTop;
>     context.beginPath();
>     context.moveTo(prevX, prevY);
>     context.lineTo(currX, currY);
>     context.strokeStyle = "cadetblue";
>     context.lineWidth = "2";
>     context.stroke();
>     context.closePath();    }   }
> 
>    function stop(event) {    if (isDrawing) {
>     context.stroke();
>     context.closePath();
>     isDrawing = false;    }   }
>      function clearSign() {    context.clearRect(0,0,w,h);   }
> 
>    canvas = document.getElementById("signatureCanvas");
>      context = canvas.getContext("2d");
>      context.strokeStyle = "black";   context.lineWidth = "2";
>      drawingUtil = new DrawingUtil(canvas);
>       alert('hi');
> 
>    function saveSignature() {    var strDataURI = canvas.toDataURL(); 
> strDataURI = strDataURI.replace(/^data:image\/(png|jpg);base64,/, "");
> var accId = location.href.split('=')[1];    accountId = accId;    var
> result = CaptureSignatureController.saveSignature(strDataURI, accId,
> processResult);   }
> 
>    function processResult(result) {    alert(JSON.stringify(result)); 
> window.location.href = '/'+accountId;   }
> 
>   
> 
>   </script>


 <div class="container">
   <h1 class="labelCol vfLabelColTextWrap ">Record Signature:</h1>
   <canvas id="signatureCanvas" height="100px" width="350px" style="border: 3px solid antiquewhite; border-radius: 8px;" ></canvas>
  </div><br/>

Issue

Even if i add normal HTML tags anywhere inside the form i am not able to draw anything. Below is the eg if i add this on the page it stopped working,if i remove it started working again.

I need urgent help in this thanks.

<table width="100%">
          <tr>
            <td width="5%"></td>
             <td width="15%"><apex:outputText >Upload</apex:outputText></td>

          </tr> 
     </table>




I have button on Opportunity on click oh which i am opening a VF page window .After opening the URl becomes

https://c.cs16.salesforce.com/apex/VFpage

On Click of save button i am closing the opoup window and refreshing parent window but when i close it it show a javascript popup error after closing the window.It says

A problem with the OnClick JavaScript for this button or link was encountered:

Blocked a frame with origin "https://cs16.salesforce.com" from accessing a cross-origin frame.




I know this error is coming because the URL are different but i dont know how to solve this issue.

Can someone tell me how to solve that issue.Its urgent for me.

I am opening a POPup window..which i am opening a VF page onlclick of a custom button.I Want to close the child window and redirect the parent window to email author page with some parameters/

https://cs16.salesforce.com/_ui/core/email/author/EmailAuthor?doc_id=00Pf0000000x1HuEAI&p3_lkid=006f0000004fKcj


I know how to close the child window but can someone tell me to redirect the parent window

function myClose(){

    self.close();
    window.opener.location.href="/{!$CurrentPage.parameters.Id}";

    //you could also use self.close();   
    }


I would really appreciate.

Thanks
I am opening a pop up VF page as 'render as pdf'.I have created a button Save and on click on save i am closing the pop window and saving PDf to opportunity.

Issue

When i am saving the code when calling the savePdf method without rerender and oncomplete.Its saving the attachment and i am able to open the attachment in opportunity without issue.When i am using either using rerender or oncomplete i am able to save the attachment but it says ".'Failed to load document'"

Its been a week i am stuck please help.

<apex:form>

function myClose(){

    self.close();
    window.opener.location.href="/{!$CurrentPage.parameters.Id}";

    //you could also use self.close();   
    }
<apex:pageBlock mode="maindetail" id="thePb"> 

      <apex:pageBlockButtons >
        <apex:commandButton value="Save to Opportunity" action="{!savePdf}" oncomplete="myClose();"  />

      </apex:pageBlockButtons>
      <apex:pageMessages />

     <iframe height="600px" id="Page" name="InvoicePDF" src="/apex/GenerateQuotePDF?id={!parentId}" width="100%"></iframe>

    </apex:pageBlock>
  </apex:form>


Class

public void savePdf() {

    PageReference pdf = Page.GenerateQuotePDF;
    pdf.getParameters().put('id',parentId);
     pdf.setRedirect(true);
    // create the new attachment
  Attachment attach = new Attachment();

    // the contents of the attachment from the pdf
    Blob body;

        body = pdf.getContent();

    attach.Body = body;
    // add the user entered name
    attach.Name = 'Opportunity'+ '.pdf'; 
    attach.IsPrivate = false;
    // attach the pdf to the account
    attach.ParentId = parentId;
    attach.ContentType = 'application/pdf';
    insert attach;

  }

have created a VF page and used "render as pdf"

<apex:commandButton value="Save to Opportunity" action="{!savePdf}"  />


Its working fine when i am using above line without rerender and oncomplete but when i am adding rerender or oncomplete it is not working.I am able to save the PDF in attachment folder but when i am trying to open its showing "Unable to load document"

Even if i remove oncomplete and use Rerender then also its saving the attachment in Attachment object and when i view ,it is not loading and says "Unable to load document"

<apex:commandButton value="Save to Opportunity" action="{!savePdf}"  oncomplete="myClose();"/>

Javascript Code

function myClose(){

    self.close();
    window.opener.location.href="/{!$CurrentPage.parameters.Id}";
}


Class Code

public void savePdf() {

    PageReference pdf = Page.GenerateQuotePDF;
    pdf.getParameters().put('id',parentId);

    Attachment attach = new Attachment();

    Blob body;
    body = pdf.getContent();
    attach.Body = body;
    attach.Name = 'Opportunity'+ '.pdf'; 
    attach.IsPrivate = false;
    attach.ParentId = parentId;
    attach.ContentType = 'application/pdf';
    insert attach;

  }


Please help..

When i click on this custom button i need to fill a field with the current date and time.But some times its giving me a previous date i.e exactly 1 day prior to current date..i dont know why this is happpening..can some help me out in this..may be there is some issue with javascript...or timezone issue..as its not happening everytime...but sometime..

 

 

var SO = new sforce.SObject("Sales_Order__c");

    function fixTime(time){
       if(time < 10) {time = "0" + time};
       return time;
    }
     function fixDate(date){
      var Month = fixTime(date.getMonth() + 1);
      var Day = fixTime(date.getDate());
      var UTC = date.toUTCString();
      var Time = UTC.substring(UTC.indexOf(':')-2, UTC.indexOf(':')+6);
      var Minutes = fixTime(date.getMinutes());
      var Seconds = fixTime(date.getSeconds());
      return date.getFullYear() + "-" + Month + "-" + Day + "T" + Time;  
    }

    SO.date__c = fixDate(new Date());
updateSO = sforce.connection.update([SO]);