• pavan.elthepu1.392651269495206E12
  • NEWBIE
  • 5 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 8
    Replies
Hi,

From Javascript, I'm trying to get attachment body and saving as attachment in Salesforce. But I'm getting Failed to load error on opening attachment. Here is my code:
 
jQuery.ajax({
	type: "GET",
	url: "https://c.cs66.content.force.com/services/data/v39.0/sobjects/Attachment/00P0v000000IlLh/Body",
	beforeSend: function (xhr) {
		xhr.responseType = "arraybuffer";
		xhr.setRequestHeader('Authorization', "OAuth " + session);
		//usually not needed but when you are
		//xhr.setRequestHeader('Content-Type', 'application/pdf');
		xhr.setRequestHeader('Access-Control-Allow-Origin', '*');
		xhr.setRequestHeader('Access-Control-Allow-Methods', 'GET');
	},
	success: function (data) {
		var att = new sforce.SObject("Attachment");
		att.Name = "Pavan_JS.pdf";

		att.ContentType = 'application/pdf';
		att.Body = att.Body =   (new sforce.Base64Binary(data)).toString();
		//att.Body = window.btoa(data); - Works for txt file, but not for pdf files
		att.ParentId ="0030v000001cnSB";
		var result = sforce.connection.create([att]);	
	}
});

Note: This code is working gret for txt files, but not for pdf files. Please help me
Here is my requirement:
  1. Have a custom button on EmailAuthor Page - Completed using Chrome extension
  2. On clicking this custom button send custom email - Working Great (Used JavaScript API)
Here is the issue: Whenever I attach files from my computer onto EmailAuthor page, those attachments are not coming in my SOQL query. Example attachment id: xxxxxxx
File is displaying if I browse: https://c.cs66.content.force.com/servlet/servlet.FileDownload?file=xxxxxxx
But if I'm browsing https://c.cs66.content.force.com/xxxxxxx, getting insufficient privileges error.
Also, [SELECT Id, Body from Attachment WHERE Id='xxxxxxx'] returning 0 records.
So, can anyone please help me how to get the body of these attachments?
I just created chrome extension, and adding a button onto EmailAithor page whenever user opens EmailAithor page. On clicking this button I want to call my apex web service. How can I achieve this? Please help me. And I want to authenticate using username, and password.
Note: I want to call this webservice from my chrome extension.
Hi all,

I want to popuate merge fields in email template, and generate PDF. How can I achieve this? Please help me

Thank you,
Pavan
Hi all,

When I'm trying to send a request using HttpRequest, getting following error:
System.CalloutException: Unable to tunnel through proxy. Proxy returns "HTTP/1.0 403 Forbidden"

I added my URL to while list. Added my webservice in remote site settings? Can anybody please let me know what I'm missing?

Thank you,
Pacan
 
I just created chrome extension, and adding a button onto EmailAithor page whenever user opens EmailAithor page. On clicking this button I want to call my apex web service. How can I achieve this? Please help me. And I want to authenticate using username, and password.
Note: I want to call this webservice from my chrome extension.
Hi all,

I want to popuate merge fields in email template, and generate PDF. How can I achieve this? Please help me

Thank you,
Pavan
Hi all,

When I'm trying to send a request using HttpRequest, getting following error:
System.CalloutException: Unable to tunnel through proxy. Proxy returns "HTTP/1.0 403 Forbidden"

I added my URL to while list. Added my webservice in remote site settings? Can anybody please let me know what I'm missing?

Thank you,
Pacan
 
I'm working on a project where (already sent) emails should be saved to Salesforce and matched with the corresponding Salesforce contact.
Creating new Emails is rather straightforward. For example using the simple_salesforce python library my code looks like this:
 
from simple_salesforce import Salesforce

[…]

sf = Salesforce(instance_url=instance_url, session_id=session_id)
sf.EmailMessage.create(
    {'FromAddress': 'foo@example.com',
     'ToAddress': 'bar@example.com',
     'Subject': 'Email: Fancy Subject', 
     'TextBody': 'lorem ipsum dolor sit amet',  
     'Status': 2
    })

This successfully creates a new EmailMessage but the message is not matched to the contact (assuming bar@example.com is an exisiting contact in Salesfored). This can be seen in numerous places in the Salesforce UI. For example:
It is not part of the contact's activity history
When looking at the Email Message details, the section “Sender and Recipients” is empty
When creating new emails using the Salesforce UI, the association is done correctly. Comparing my EmailMessage objects from the ones generate by Salesforce there is one obvious difference: ActivityId is not set for my objects.
When I'm trying to set ActivityId to a matching Contact ID I receive a Malformed Request Exception INSUFFICIENT_ACCESS_OR_READONLY.

Am I missing something? Is it somehow possible to create those associations using the API?
Hi,
I have received the Attachement.Body from REST API call as mentioned in https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_sobject_blob_retrieve.htm from client side. 
When I get the blob returned and try to create a js file object,as below: 
    var body = [blobData];
    this.file = new File(body , fileName , {type: contentType , lastModifiedDate: new Date(), name: fileName} );
Now btoa(blobData) throws error Uncaught DOMException: Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range  for image/pdf. It works fine for text.
Please help to figure this out. 

Has anyone successfully created a "Copy to Clipboard" button in Visualforce?

 

I've got a method that works for Internet Explorer only ( http://www.htmlgoodies.com/beyond/javascript/article.php/3458851/Click-Its-Copied.htm) , which will be acceptable at this point, although I would prefer a cross-browser solution.

 

However, I don't seem to be able to make it work in a VF page. Here's my basic attempt:

 

 

<apex:page title="Clipboard Test" showheader="false">

	<script language="JavaScript">
		function ClipBoard()
		{
			holdtext.innerText = {!$Component.copytext}.innerText;
			Copied = holdtext.createTextRange();
			Copied.execCommand("Copy");
		}


	</script>

<body >
	<apex:outputpanel ID="copytext" >
		This text will be copied onto the clipboard when you click the button below.
	</apex:outputpanel>
	
	<TEXTAREA ID="holdtext" STYLE="display:none;">
	</TEXTAREA>
	
	<BUTTON onClick="ClipBoard();">Copy to Clipboard</BUTTON>

</body>	
	
</apex:page>

 

I am not a Javascript expert, which is making this all harder for me. Please help!

 

Thanks,

 

Jeremy

 

Hi,

 

I'm new to salesforce development. I'm trying to look at the data we have in salesforce and figure out how it is currently organized (the developer who set it up is no longer employed at my organization). I'd like to be able to access the database directly preferable through a command-line interface. Is there a way to do that? Any pointers or suggestions would be much appreciated. 

 

Thanks in advance,

 

Shirley