• Rajus
  • NEWBIE
  • 30 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 3
    Likes Received
  • 0
    Likes Given
  • 14
    Questions
  • 11
    Replies
Hi,

I have one requirement where i need to upload file from salesforce(selected from local drive) to windows server windows server 2008R2.
I want to upload it using HTML forms.I tried with the following code,
<apex:page >
  <form action="http://209.xxxxxxxxxxxx/TestInputFiles" enctype="multipart/form-data" method="post">
    <p>
    Type some text (if you like):
    <input type="text" name="textline" size="30"/>
    </p>
    <p>
    Please specify a file, or a set of files:<br></br>
    <input type="file" name="datafile" size="40"/>
    </p>
    <div>
    <input type="submit" value="Send"/>
    </div>
    </form>
</apex:page>

After clicking on upload i am getting the following error,
Server Error: 405 - HTTP verb used to access this page is not allowed.

Do we need to have any script at the server side to recieve uploaded files or no need?
Can any one please put some light on this.


Thanx in Advance.


Thanks,
Raj.
  • June 26, 2014
  • Like
  • 0
Hi All,
I am getting some un expected characters in word document some thing like below.

•Hospital
•Clinic
•Nursing Home
•CRO

I tried all possible ways to get rid of this issue but no use.Can any one please help me out to sort out this issue.
Follwoing is my visualforce code:
<apex:page standardcontroller="Business_Requirement__c" standardStylesheets="false" showheader="false" contentType="application/rtf;charset=ISO-8859-1#Word_Document.doc" extensions="GenerateReport_BR" cache="true">
    <html xmlns:w="urn:schemas-microsoft-com:office:word">
    <apex:outputText value="{!PrintView}" escape="false"/>
    <body>
    <h2>Business Requirement</h2> 
    <h3>This section of the User Requirement Specification contains all of the business requirements of the system.
    These requirements are written at a level of detail sufficient to enable designers to design a system that will
    satisfy those requirements and testers to test that the system satisfies those requirements.
    (Static from one of the field from Release Plan)</h3>
    <table width="100%" border="1" cellspacing="0" cellpadding="0" >
            <tr>
                <th>BR#</th>
                <th>Requirement Summary</th>
                <th>Use Case</th>
            </tr>
            <tr>
                <td>{!CMAX__Business_Requirement__c.Name}</td>
                <td><apex:outputtext escape="false" value="{!CMAX__Business_Requirement__c.CMAX__Business_Requirements_Summary__c}"/></td>
                <td><apex:outputtext escape="false" value="{!CMAX__Business_Requirement__c.CMAX__Use_Case__c}"/></td>
            </tr>
    </table>
</body>
     </html>
   
</apex:page>
  • April 22, 2014
  • Like
  • 0
Hi All,

I am getting some invalid images at the end of the MS-Word doc like below.

Invalid footer
I am using apex:page tag like below.
<apex:page standardcontroller="Account" contentType="application/msword; charset=Windows-1252" extensions="GenerateReport_BR" language="en" cache="true">

Can any one please let me know where i am doing mistake .

Thanks,
Raj.

  • April 07, 2014
  • Like
  • 0
Hi All,
I want to rename the confirm box buttons(OK,CANCEL) with 'Yes' and 'NO'.
Is there any way to do it using Javascript.


Thanks,
Raj.
  • April 07, 2014
  • Like
  • 0
Hi All,
I have one simple map like below.
Map<string,string> keyAndValues = new Map<string,string>();
keyAndValues.put('ABCD','1234');

Now i want to check whether the string 'abcd' exists in Keys of Map or not.
I ll write like this,
if(keyAndValues.containskey('abcd')){
    system.debug('Key exists in map');
}

Here It will return false as it ll check with case sensitivity.

But i want to ignore case sensitivity and want to search vth case insensivity.Is there any way to do like this.
If any one have idea please let me know.


Thanks in Advance.

Rajesh.
  • March 31, 2014
  • Like
  • 0
Hi All,

I have one list some thing like below.
List<string> possiblevalues = new list<string>{'abc gh', 'def', 'ghi'};

and One string some thing like below
String str = 'Hello guys Hello world abc gh ';

Now i have to look for each string of possiblevalues in str.Is there any simple method to find out whether the string is present in the str or not.
I know the simple way which is,

for(string s:possiblevalues)
{
       if(str.contains(s);
            string matchvalue = s;

}
But this technique will loop through all elements of list.But i need more efficient way without using for loops for this.


If some one find the better approach pleas let me know.


Thanks,
Raj.
  • February 25, 2014
  • Like
  • 0
Hi All,
I am getting Parameter_Tampering Issue in my apex code when i submit package for security review.It is coming specifically when i use string.escapeSingleQuotes(variable) to avoid SOQL-SOSL injection.

Do any one have idea about How to get rid of this issue.It ll be more helpful to me.

Thanks,
Rajesh.
  • January 09, 2014
  • Like
  • 0

Hi All,

 

I am trying to replace all occurances of a perticular string in javascript ,but the value is not getting change

Ex 

Var str = 'Hello_world_congrats';

str = str.replace(/_/g,'&');

 

In this code i am trying to convert all '_' characters with '&' but the value is not getting change.

 

 

Can any one please let me know what's wrong in this.

Thanks in advance.

 

 

Raj.

  • November 11, 2013
  • Like
  • 0

Hi All,

 

I am uploading a file to an external system using Html's input type submit option.Now i want to attach a file to attachments of Account detail page when my file uploaded to external system.

I am using this format to upload file to external system,

 

<form action="{!bucketName}" method="post" enctype="multipart/form-data" target="_target" >
<input type="hidden" name="key" id="keyvalue" /><!-- value="uploads/Tabs_limitation.png" -->
<input type="hidden" name="AWSAccessKeyId" id="AWSAccessKeyId"/>
<input type="hidden" name="policy" id="policy"/>
<input type="hidden" name="signature" id="signature"/>
<input type="hidden" id="aclid" name="acl" value="{!acl}"/>
<input type="hidden" name="Content-Type" value="application/octet-stream" />
<input type="hidden" id="success_action_redirect" name="success_action_redirect" value="https://c.na15.visual.force.com/apex/SuccessRedirect" />

<input class="btn" type="submit" value="Upload" onclick="return upload();"/>

 

In order to attach a file in Notes and Attachments we need Body,ContentType,ParentID,Name.Here i can retreive the file name, Parent id .But dont know how to get the Content type and Body.

 

Could any one please help me out to get the Body and ContentType from the above format,

 

Thanks in advance

 

 

 

Raj.

 

 

  • November 11, 2013
  • Like
  • 1

Hi,

I want to implement a tree structure in visualforce page some thing like the structure from this link http://ludo.cubicphuse.nl/jquery-treetable/

 

Is it possible to implement like above.If yes can any one please provide any simple example to implement this.

Thanks in Advance.

 

 

Raj.

  • November 08, 2013
  • Like
  • 0

Hi All,

 

I have created bucket in amazon s3.Now i want to navigate to that bucket's page from salesforce .For that i created a link like this.https://s3.amazonaws.com/bucketname and also tried https://bucketname.s3.amazonaws.com. But its not working fine,telling No such bucket exists.

 

Could any one please let me know where i am doing wrong.

 

 

Thanks,

Raj.

  • November 04, 2013
  • Like
  • 1

Hi All,

 

I am facing an issue while trying to get the  bucket objects from amazon s3 using rest api.Could any one please help me out on this.

 

Following is my code:

 

string timestamp = datetime.now().formatGmt('EEE, d MMM yyyy HH:mm:ss Z');
string bucket = 'xyz';
string stringToSign='GET\n\n\n'+timestamp+'\n/'+bucket+'/';
Blob bsig = Crypto.generateMac('hmacSHA1',Blob.valueOf(stringToSign),Blob.valueof('xxxxxxxxxxxxxxxxxxxxx'));
string Signature= EncodingUtil.base64Encode(bsig);
HttpRequest req = new HttpRequest();
string endpoint = 'https://s3.amazonaws.com';
req.setMethod('GET');
req.setHeader('Host',bucket+'.'+'s3.amazonaws.com');
req.setEndpoint(endpoint);
Http http = new Http();
string AWSAccessKeyId='xxxxxxxxxxxxxxxx';
req.setHeader('Authorization','AWS '+AWSAccessKeyId+':'+signature);
req.setHeader('Date',timestamp);
HttpResponse res = http.send(req);
system.debug('Body is'+res.getBody());

 

I am getting the Signature mismatch error for the above code.Any guidence appreciated.

 

 

Thanks,

Raj

 

  • October 31, 2013
  • Like
  • 1

Hi All,

I have created one search functionality where users can select the filter criteria and fields to display in the search results,

In search results i want to provide a link for Name field .So that users can open that perticaular record.

I know how to it for static columns. It will be some thing like <apex:outputLink value="{!result.id}">{!result.Name}</apex:outputLink>

 

Now i want do like this for the Name field which will be selected dynamically.

Following is my visualforce code which i use to display the search results.

 

<apex:pageblockTable value="{!masterlist}" var="rec" rendered="{!if(masterlist.size>0,true,false)}">


<apex:repeat value="{!selectedfields}" var="FieldLable">

<apex:column value="{!rec[FieldLable]}" />
</apex:repeat>
</apex:pageblockTable>

 

So can any one please give any idea that where and how should i change the code .so that i can provid the link comfirtably.

 

 

Thanks,

Rajesh.

  • October 11, 2013
  • Like
  • 0

Hi All,

 

I am facing one issue since two weeks .The issue is i am not able to authenticate the amazon s3 Rest  request properly and getting the following error.

 

Error:The request signature we calculated does not match the signature you provided.Check your key and signing method.

 

Follwoing is my code:

String dateString = Datetime.now().formatGmt('EEE, dd MMM yyyy HH:mm:ss Z');
system.debug('=========='+dateString);
string stringToSign = 'GET\n\n\n'+dateString';
Blob mac = Crypto.generateMac('hmacSHA1', Blob.valueOf(stringToSign), Blob.valueOf('xxxxxxxx'));
stringToSign = EncodingUtil.base64Encode(mac);
//stringToSign = EncodingUtil.urlEncode(stringToSign, 'UTF-8');
httpRequest con = new HttpRequest();
system.debug('**********'+stringToSign);
con.setHeader('Authorization', 'AWS xxxxxx:'+stringToSign);
con.setEndPoint('https://s3.amazonaws.com');
con.setHeader('Host','xxxxx.s3.amazonaws.com');
system.debug('====date format'+dateString);
con.setHeader('Date',dateString);
//con.setHeader('Content-Type','application/xml');
con.setMethod('GET');
Http http = new Http();
HTTPResponse res = http.send(con);
system.debug('========'+res.getBody());

 

 

Can any one please help me out on this.

Thanx in advance.

  • October 11, 2013
  • Like
  • 0

Hi All,

 

I am uploading a file to an external system using Html's input type submit option.Now i want to attach a file to attachments of Account detail page when my file uploaded to external system.

I am using this format to upload file to external system,

 

<form action="{!bucketName}" method="post" enctype="multipart/form-data" target="_target" >
<input type="hidden" name="key" id="keyvalue" /><!-- value="uploads/Tabs_limitation.png" -->
<input type="hidden" name="AWSAccessKeyId" id="AWSAccessKeyId"/>
<input type="hidden" name="policy" id="policy"/>
<input type="hidden" name="signature" id="signature"/>
<input type="hidden" id="aclid" name="acl" value="{!acl}"/>
<input type="hidden" name="Content-Type" value="application/octet-stream" />
<input type="hidden" id="success_action_redirect" name="success_action_redirect" value="https://c.na15.visual.force.com/apex/SuccessRedirect" />

<input class="btn" type="submit" value="Upload" onclick="return upload();"/>

 

In order to attach a file in Notes and Attachments we need Body,ContentType,ParentID,Name.Here i can retreive the file name, Parent id .But dont know how to get the Content type and Body.

 

Could any one please help me out to get the Body and ContentType from the above format,

 

Thanks in advance

 

 

 

Raj.

 

 

  • November 11, 2013
  • Like
  • 1

Hi All,

 

I have created bucket in amazon s3.Now i want to navigate to that bucket's page from salesforce .For that i created a link like this.https://s3.amazonaws.com/bucketname and also tried https://bucketname.s3.amazonaws.com. But its not working fine,telling No such bucket exists.

 

Could any one please let me know where i am doing wrong.

 

 

Thanks,

Raj.

  • November 04, 2013
  • Like
  • 1

Hi All,

 

I am facing an issue while trying to get the  bucket objects from amazon s3 using rest api.Could any one please help me out on this.

 

Following is my code:

 

string timestamp = datetime.now().formatGmt('EEE, d MMM yyyy HH:mm:ss Z');
string bucket = 'xyz';
string stringToSign='GET\n\n\n'+timestamp+'\n/'+bucket+'/';
Blob bsig = Crypto.generateMac('hmacSHA1',Blob.valueOf(stringToSign),Blob.valueof('xxxxxxxxxxxxxxxxxxxxx'));
string Signature= EncodingUtil.base64Encode(bsig);
HttpRequest req = new HttpRequest();
string endpoint = 'https://s3.amazonaws.com';
req.setMethod('GET');
req.setHeader('Host',bucket+'.'+'s3.amazonaws.com');
req.setEndpoint(endpoint);
Http http = new Http();
string AWSAccessKeyId='xxxxxxxxxxxxxxxx';
req.setHeader('Authorization','AWS '+AWSAccessKeyId+':'+signature);
req.setHeader('Date',timestamp);
HttpResponse res = http.send(req);
system.debug('Body is'+res.getBody());

 

I am getting the Signature mismatch error for the above code.Any guidence appreciated.

 

 

Thanks,

Raj

 

  • October 31, 2013
  • Like
  • 1
Hi All,
I am getting some un expected characters in word document some thing like below.

•Hospital
•Clinic
•Nursing Home
•CRO

I tried all possible ways to get rid of this issue but no use.Can any one please help me out to sort out this issue.
Follwoing is my visualforce code:
<apex:page standardcontroller="Business_Requirement__c" standardStylesheets="false" showheader="false" contentType="application/rtf;charset=ISO-8859-1#Word_Document.doc" extensions="GenerateReport_BR" cache="true">
    <html xmlns:w="urn:schemas-microsoft-com:office:word">
    <apex:outputText value="{!PrintView}" escape="false"/>
    <body>
    <h2>Business Requirement</h2> 
    <h3>This section of the User Requirement Specification contains all of the business requirements of the system.
    These requirements are written at a level of detail sufficient to enable designers to design a system that will
    satisfy those requirements and testers to test that the system satisfies those requirements.
    (Static from one of the field from Release Plan)</h3>
    <table width="100%" border="1" cellspacing="0" cellpadding="0" >
            <tr>
                <th>BR#</th>
                <th>Requirement Summary</th>
                <th>Use Case</th>
            </tr>
            <tr>
                <td>{!CMAX__Business_Requirement__c.Name}</td>
                <td><apex:outputtext escape="false" value="{!CMAX__Business_Requirement__c.CMAX__Business_Requirements_Summary__c}"/></td>
                <td><apex:outputtext escape="false" value="{!CMAX__Business_Requirement__c.CMAX__Use_Case__c}"/></td>
            </tr>
    </table>
</body>
     </html>
   
</apex:page>
  • April 22, 2014
  • Like
  • 0
Hi All,

I am getting some invalid images at the end of the MS-Word doc like below.

Invalid footer
I am using apex:page tag like below.
<apex:page standardcontroller="Account" contentType="application/msword; charset=Windows-1252" extensions="GenerateReport_BR" language="en" cache="true">

Can any one please let me know where i am doing mistake .

Thanks,
Raj.

  • April 07, 2014
  • Like
  • 0
Hi All,

I have one list some thing like below.
List<string> possiblevalues = new list<string>{'abc gh', 'def', 'ghi'};

and One string some thing like below
String str = 'Hello guys Hello world abc gh ';

Now i have to look for each string of possiblevalues in str.Is there any simple method to find out whether the string is present in the str or not.
I know the simple way which is,

for(string s:possiblevalues)
{
       if(str.contains(s);
            string matchvalue = s;

}
But this technique will loop through all elements of list.But i need more efficient way without using for loops for this.


If some one find the better approach pleas let me know.


Thanks,
Raj.
  • February 25, 2014
  • Like
  • 0
Hi All,
I am getting Parameter_Tampering Issue in my apex code when i submit package for security review.It is coming specifically when i use string.escapeSingleQuotes(variable) to avoid SOQL-SOSL injection.

Do any one have idea about How to get rid of this issue.It ll be more helpful to me.

Thanks,
Rajesh.
  • January 09, 2014
  • Like
  • 0

Hi All,

I have created one search functionality where users can select the filter criteria and fields to display in the search results,

In search results i want to provide a link for Name field .So that users can open that perticaular record.

I know how to it for static columns. It will be some thing like <apex:outputLink value="{!result.id}">{!result.Name}</apex:outputLink>

 

Now i want do like this for the Name field which will be selected dynamically.

Following is my visualforce code which i use to display the search results.

 

<apex:pageblockTable value="{!masterlist}" var="rec" rendered="{!if(masterlist.size>0,true,false)}">


<apex:repeat value="{!selectedfields}" var="FieldLable">

<apex:column value="{!rec[FieldLable]}" />
</apex:repeat>
</apex:pageblockTable>

 

So can any one please give any idea that where and how should i change the code .so that i can provid the link comfirtably.

 

 

Thanks,

Rajesh.

  • October 11, 2013
  • Like
  • 0

Hi All,

 

I am facing one issue since two weeks .The issue is i am not able to authenticate the amazon s3 Rest  request properly and getting the following error.

 

Error:The request signature we calculated does not match the signature you provided.Check your key and signing method.

 

Follwoing is my code:

String dateString = Datetime.now().formatGmt('EEE, dd MMM yyyy HH:mm:ss Z');
system.debug('=========='+dateString);
string stringToSign = 'GET\n\n\n'+dateString';
Blob mac = Crypto.generateMac('hmacSHA1', Blob.valueOf(stringToSign), Blob.valueOf('xxxxxxxx'));
stringToSign = EncodingUtil.base64Encode(mac);
//stringToSign = EncodingUtil.urlEncode(stringToSign, 'UTF-8');
httpRequest con = new HttpRequest();
system.debug('**********'+stringToSign);
con.setHeader('Authorization', 'AWS xxxxxx:'+stringToSign);
con.setEndPoint('https://s3.amazonaws.com');
con.setHeader('Host','xxxxx.s3.amazonaws.com');
system.debug('====date format'+dateString);
con.setHeader('Date',dateString);
//con.setHeader('Content-Type','application/xml');
con.setMethod('GET');
Http http = new Http();
HTTPResponse res = http.send(con);
system.debug('========'+res.getBody());

 

 

Can any one please help me out on this.

Thanx in advance.

  • October 11, 2013
  • Like
  • 0

Hi all,

 

I implemented a method to upload an Attachment to Amazon S3 but I'm having this issue : AWS authentication requires a valid Date or x-amz-date header

 

Any help is appreciated.

 

Attachment attachment = [Select Id, ContentType, Body, BodyLength from Attachment limit 1];
      //Set<Id> ids = new Map<Id,Attachment>(attachments).keySet();
      AWSKeys credentials = new AWSKeys('Keys');
      S3.AmazonS3 as3 = new S3.AmazonS3(credentials.key,credentials.secret);
      
      Datetime now = DateTime.now();
      String formattednow = now.formatGmt('yyyy-MM-dd')+'T'+now.formatGmt('HH:mm:ss')+'.'+now.formatGMT('SSS')+'Z';
      
      String stringtosign = 'PUT \n\n';
      stringtosign += attachment.ContentType + '\n';
      stringtosign += formattednow + '\n';
      stringtosign += '/mybucket/' + attachment.Id;
      Blob mac = Crypto.generateMac('HMacSHA1', blob.valueof(stringtosign),blob.valueof(as3.secret)); 
      String signature = EncodingUtil.base64Encode(mac);
      
      HttpRequest req = new HttpRequest(); 
 
     //Set HTTPRequest Method
     req.setMethod('PUT');
   
     //Set HTTPRequest header properties
     req.setHeader('content-type', attachment.ContentType);
     req.setHeader('Content-Length',String.valueOf(attachment.BodyLength));
     req.setHeader('Date', formattednow);
     req.setHeader('Authorization', 'AWS ' + as3.key + ':' + signature);
     req.setEndpoint('http://s3.amazonaws.com');
     
      try {
            Http http = new Http();
           //Execute web service call here      
           HTTPResponse res = http.send(req);
         
   } catch(System.CalloutException e) {
      System.debug('===================EXCEPTION ' + e.getMessage() + e.getStackTraceString());
   }  

 

  • December 12, 2012
  • Like
  • 0

Hi,

 

I have executed the following code which makes a call to Amazon web services and I have receieved the following exception: 

 

<Response><Errors><Error><Code>InvalidParameterValue</Code><Message>Value (2011-8-30'T'6:53:6.495'Z') for parameter Timestamp is invalid. Must be in ISO8601 format.</Message></Error></Errors><RequestID>41aa0620-6f49-48cb-aead-bed311db49d1</RequestID></Response>

 

It will be great if someone helps to fix this problem and also posts AWS S3 REST sample code. 

 

Please replace 'AWS Secret Key' and 'AWS KEY' values before executing this code.

 

public with sharing class S3Rest {

public static void testAlexaWSForAmazon() {

       // The date format is yyyy-MM-dd'T'HH:mm:ss.SSS'Z' 

       DateTime d = System.now();

       String timestamp = ''+ d.year() + '-' +d.month() + '-' +d.day() + '\'T\'' +d.hour() + ':' +d.minute() + ':' +d.second() + '.' +d.millisecond() + '\'Z\'';

       String timeFormat = d.formatGmt(timestamp);

       String urlEncodedTimestamp = EncodingUtil.urlEncode(timestamp, 'UTF-8');

       String action = 'UrlInfo';

       String inputStr = action + timeFormat;

       String algorithmName = 'HMacSHA1';

       Blob mac = Crypto.generateMac(algorithmName, Blob.valueOf(inputStr),Blob.valueOf('AWS Secrect key'));

       String macUrl = EncodingUtil.urlEncode(EncodingUtil.base64Encode(mac), 'UTF-8');

       String urlToTest = 'amazon.com';

       String version = '2005-07-11';

       String endpoint = 'http://awis.amazonaws.com/';

       String accessKey = 'AWS KEY';

       HttpRequest req = new HttpRequest();

       req.setEndpoint(endpoint +'?AWSAccessKeyId=' + accessKey +'&Action=' +

                                 action +'&ResponseGroup=Rank&Version=' +

                                  version +'&Timestamp=' + urlEncodedTimestamp +

                                  '&Url=' + urlToTest +'&Signature=' + macUrl); 

        req.setMethod('GET');

        Http http = new Http();

       try {

             HttpResponse res =   http.send(req);

             System.debug('STATUS:'+res.getStatus());

             System.debug('STATUS_CODE:'+res.getStatusCode());

             System.debug('BODY: '+res.getBody());

        } catch(System.CalloutException e) {

              System.debug('ERROR: '+ e);

         }

   }

}

 

Thanks,

Rag

I'm trying to write a simple trigger that renames a record. I keep getting the error "CallLineItemRename: execution of BeforeInsert caused by: System.SObjectException: DML statment cannot operate on trigger.new or trigger.old: Trigger.CallLineItemRename: line 18, column 9" . What am I missing here?

 

 

 

trigger CallLineItemRename on Call_Line_Item__c (before insert, before update) { // this triger renames the call line item id to be // the specified inventory item name or the product name List<Call_Line_Item__c> callItems = new List<Call_Line_Item__c>(); callItems = Trigger.new; for (Call_Line_Item__c callItem : callItems) { //check if inventory or product was specified if (callItem.Inventory_Item__c <> NULL) { callItem.Name = callItem.Inventory_Item__r.Name; callItem.Name = 'inv item name'; } else if (callItem.Products__c <> NULL) { callItem.Name = callItem.Products__r.Name; } } update callItems; }