• Swati Taunk
  • NEWBIE
  • 0 Points
  • Member since 2012
  • Salesforce Developer
  • IBM

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 6
    Replies
Crypto class provides methods to Sign and Verify signature using certificate. 
- signWithCertificate(algorithmName, input, certDevName)
- verify(String algorithmName, Blob data, Blob signature, String certDevName)

Here the signWithCertificate method expects a privateKey. I have the Signing certificate uploaded in Certificate and Key Management page.

But verify method expects a public key. I have the public certificate provided by the 3rd party application but where can I upload this public certificate in salesforce so it can be used in the verify method? I am not able to upload on Certificate and Key Management page. It gives an error saying: Private Key is missing. 
Crypto (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_restful_crypto.htm) class supports only AES algorithm for Encryption and Decrypion. I have a usecase where I need to encrypt my HTTP request payload using a certificate which supports RSA Encryption algorithm. 
So, should I write custom code to implement RSA encruption/Decryption algorithm? Is this the recommended approach/Best Practice? 
I have to integrate AWS Machine Learning service with Salesforce. I implemented JavaScript SDK [http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/MachineLearning.html#predict-property] and it is working well.

But I have to implement API using batch apex and schedule the batch class. [http://docs.aws.amazon.com/machine-learning/latest/APIReference/API_Predict.html]

I managed to implement this using apex but I get incorrect response and also same response for all the records (batch size is 1). Any ideas?
I get different responses for same record. Response received from SDK is correct.

Response from http request-

"{"Prediction":{"details":{"Algorithm":"SGD","PredictiveModelType":"BINARY"},"predictedLabel":"0","predictedScores":{"0":0.03352721035480499}}}"

Response from SDK -

"{"Prediction":{"details":{"Algorithm":"SGD","PredictiveModelType":"BINARY"},"predictedLabel":"1","predictedScores":{"1":0.9637616872787476}}}"
Hello,

I have created a mobile community app on angular JS and VF. Community users are logged in by SSO. There is a custom object with notes & attachment related list.
Community users are not able to view images from attachment object.  [ <img src="<SiteURL>/servlet/servlet.FileDownload?file=attachmentID" /> ]

Any idea why attachments are not visible to community users?
 
Hello,


Code:

global class CurrencyExchangeRateScheduler implements Schedulable
{
    public String sessionId;
  
    public CurrencyExchangeRateScheduler()
    {
        String username = 'username';
        String password = 'password+security_token';
      
        partnerSoapSforceCom.Soap sp = new partnerSoapSforceCom.Soap();
      
        partnerSoapSforceCom.LoginResult loginResult = sp.login(username, password);
          
        sessionId = loginResult.sessionId;
       
    }
  
    global void execute(SchedulableContext ctx)
    {
        UpdateDailyCurrencyExchangeRate(sessionId);
    }
  
    @Future(callout=true)
    public static void UpdateDailyCurrencyExchangeRate(string sessionId)
    {
        system.debug('sessionId: '+sessionId);
      
        ...
        ...
        ...
        ...
 
 
        Http h = new Http();
        HttpRequest req = new HttpRequest();
        req.setHeader('Authorization', 'OAuth ' + sessionId);
        req.setHeader('Content-Type', 'application/json');
        req.setMethod('POST');
      
        for(CurrencyType currType : currencies)
        {
            if(!currType.IsCorporate)
            {
                req.setEndpoint(URL.getSalesforceBaseUrl().toExternalForm() + '/services/data/v28.0/sobjects/CurrencyType/'+currType.id+'?_HttpMethod=PATCH');

                req.setBody('{ "ConversionRate" : 2.5 }');

                HttpResponse response = h.send(req);    
   
                system.debug('response: '+response);
             }
        }
    }
}

Debug: response: System.HttpResponse[Status=Unauthorized, StatusCode=401]

The code works perfectly fine when I am loggedin to the org. But when the class is scheduled and I am not loggedin, the response status is 'Unauthorized' and the currency table is not updated.

How can I get the session Id when User is not loggedin?

I have implemented an email service where I parse the email and create an opportunity record. It works perfect.

Now I have an issue in the following scenario:

Scenario:
email is sent from email address A to B,
from B it is forwarded to C (SF email address).
When an email is sent from address B, It is assumed as it has been forwarded by some other email address, I need that original email address.
So in that case I search for keywords ‘From’ , ‘To’, etc to find the actual email address (i.e. A). This also works perfectly fine.

The issue is:
the emails are sent from around the globe. So in some emails, the language is other that English.
For ex:
———- Weitergeleitete Nachricht ———-
Datum:
Betreff:
Absender:
An:

 

instead of


———- Forwarded message ———-
date:
subject:
sender:
to:

 

 

Please suggest how can I handle different languages?

Crypto (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_restful_crypto.htm) class supports only AES algorithm for Encryption and Decrypion. I have a usecase where I need to encrypt my HTTP request payload using a certificate which supports RSA Encryption algorithm. 
So, should I write custom code to implement RSA encruption/Decryption algorithm? Is this the recommended approach/Best Practice? 
Hello,

I have created a mobile community app on angular JS and VF. Community users are logged in by SSO. There is a custom object with notes & attachment related list.
Community users are not able to view images from attachment object.  [ <img src="<SiteURL>/servlet/servlet.FileDownload?file=attachmentID" /> ]

Any idea why attachments are not visible to community users?
 
Hello,


Code:

global class CurrencyExchangeRateScheduler implements Schedulable
{
    public String sessionId;
  
    public CurrencyExchangeRateScheduler()
    {
        String username = 'username';
        String password = 'password+security_token';
      
        partnerSoapSforceCom.Soap sp = new partnerSoapSforceCom.Soap();
      
        partnerSoapSforceCom.LoginResult loginResult = sp.login(username, password);
          
        sessionId = loginResult.sessionId;
       
    }
  
    global void execute(SchedulableContext ctx)
    {
        UpdateDailyCurrencyExchangeRate(sessionId);
    }
  
    @Future(callout=true)
    public static void UpdateDailyCurrencyExchangeRate(string sessionId)
    {
        system.debug('sessionId: '+sessionId);
      
        ...
        ...
        ...
        ...
 
 
        Http h = new Http();
        HttpRequest req = new HttpRequest();
        req.setHeader('Authorization', 'OAuth ' + sessionId);
        req.setHeader('Content-Type', 'application/json');
        req.setMethod('POST');
      
        for(CurrencyType currType : currencies)
        {
            if(!currType.IsCorporate)
            {
                req.setEndpoint(URL.getSalesforceBaseUrl().toExternalForm() + '/services/data/v28.0/sobjects/CurrencyType/'+currType.id+'?_HttpMethod=PATCH');

                req.setBody('{ "ConversionRate" : 2.5 }');

                HttpResponse response = h.send(req);    
   
                system.debug('response: '+response);
             }
        }
    }
}

Debug: response: System.HttpResponse[Status=Unauthorized, StatusCode=401]

The code works perfectly fine when I am loggedin to the org. But when the class is scheduled and I am not loggedin, the response status is 'Unauthorized' and the currency table is not updated.

How can I get the session Id when User is not loggedin?
Hi all,

I've spent the majority of my day trying to find a solution for this issue and I'm having no luck. I'm still a bit of a beginner so bare with me.

I have a VisualForce page on a Communities site that is designed to list the standard Attachment object records from the community $Users related contact. This page is intended to list the Description of the attachment as well as a link to download it. I have a supporting controller that runs a Select query to retrieve the contacts attachments.

Here is a snippet from the page:
<apex:repeat var="doc" value="{!candidate.Attachments}">
                        <li>
                            <h4><apex:outputText value="{!doc.Description}"/></h4>
                            <div class="doc-h">
                            <apex:outputLink value="{!URLFOR($Action.Attachment.Download, doc.Id)}" target="_blank">
                                &nbsp;
                            </apex:outputLink>
                            </div>
                        </li>
                </apex:repeat>

This renders exactly how I would like it to render, and correctly displays the description and the link. However, if I browse to one of many of the links generated by {!URLFOR($Action.Attachment.Download, doc.Id)}, I receive an "Insufficient Privileges" error. I've tried hardcoding the URL and ID and receive the same error.

It generates a link like this: {community site}/servlet/servlet.FileDownload?retURL=%2Fcandidates%2Fapex%2FSupportingDocuments&file=00PN0000000ZZUBMA4

I would have expected that this is profile related, but it doesn't seem to be the case. This is what I've attempted to do to resolve this issue so far:
* Ensure that the community user's profiles has full RCED access to the Account and Contact objects and their fields.
* Ensured that the Site Guest User profile has full RCED access to the Account and Contact objects and their fields.
* Confirmed that share settings and OWD were set to public read/write for the Attachment objects parent (so Account and Contact).
* Read somewhere to try using the 15 digit ID rather than the 18 Digit, to no avail.
* Tried using traditional <a href="">Links</a> instead of apex:OutputLink.

Funnily enough, on the same page with the same user,  I have functionality that allows the user to upload an attachment (which creates an Attachment record against the sites related contact) and this works perfectly.

I've seen a few similar posts such as  here (https://developer.salesforce.com/forums?id=906F000000099hpIAA)  and here (https://developer.salesforce.com/forums?id=906F00000008y5hIAA) but I'm still having no luck. If anybody has experienced something like this before and knows of a possible solution (even if it seems far fetched) then I'd love to hear it!

Cheers,

Dion

We need to show a multi-picklist on visual force Page.   The lines to be visible had put as 10.  But it is showing only single line.

So, we increased the height of the input filed, then, the buttons (right arrow, left arrow) are being multiplied on the screen. 

Here im putting the image:

 

 


        <apex:pageblocksection title="Prodcut Interest" id="new3">
             <apex:pageBlockSectionItem dataStyle="height:200px;">
               <apex:outputLabel for="Product_Interest" value="Product Interest" styleClass="labels" style="height:100px;"/>
               <apex:inputField value="{!cont.Product_Interest__c}" id="Product_Interest" style="height:80px;"/>
            </apex:pageBlockSectionItem>
        </apex:pageblocksection>

Multip picklist with height

 

Please let me know any solution.

Hi,

 

I am looking for some guidance on how to change the status of a case to "updated by customer" when the customer sends an email reply to case. This rule cannot fire on the intial email the customer sends to create the case. I'm having difficulty figuring out which criteria I should use in this formula.

 

Any help would be greatly appreciated.

  • December 04, 2009
  • Like
  • 0
Hello experts,
 
I want to know the way of using condition in visualforce page. I have a custom object 'Person__c' having few fields. Two of them are:
Name, Active(Checkbox), Birthday, Age(Numberic)
 
What I want to do is list values in these fields in visualforce page. While displaying, I want to display:
 'Minor' if Age<16, otherwise 'Adult'
 
I want to be able to do this in any of the following 3 ways:
 
1. By using If clause in apex page
2. By passing 'Age' as a parameter to my extended controller
3. And using case (or similar) in SOQL
 
Below is my code:
 
Code:
<apex:page standardController="Person__c" extensions="PersonExtension">
 <apex:form>
  <apex:pageblock title="My Persons Infos">
   <apex:pageblockList value="{!PersonList}" var="p">
    <apex:column value="{!p.Name}"/>
    <apex:column value="{!p.Active__c}"/>
    <apex:column value="{!p.Birthday__c}"/>
    <apex:column value="{!p.Age__c}"/>
    <apex:column value="{!anystring}"/>
    <apex:column value="{!IF((p.Age__c>16),'Adult','Minor')}"/>
   </apex:pageblockList>
  </apex:pageblock>
 </apex:form>
</apex:page>


public class PersonExtension{

  private final Person__c person;

  public PersonExtension(ApexPages.StandardController stdController){
    this.person= (Person__c)stdController.getRecord();
  }

  public Person__c[] getPersonList(){
    return [Select p.Id, p.Name, p.Age__c, Birthday__c, p.Active__c from Person__c p];
  }

  public String getAnyString(){
    return 'Anything';
  }
}

The error I get is: Error: Syntax error. Missing ')'
 
If I change the if condition to: <apex:column value="{!IF((p.Age__c<16),'Minor','Adult')}"/>
The error will be: Error: Syntax error. Found 'lt'
 
Even a simple clause is not working:

<apex:column value="{!IF(CONTAINS({!anystring}, 'Anything'),True, False)}"/>
 
1. What is wrong in my code? Can I use IF condition in this way?
2. Can I pass a parameter (Age in above case) to my controller and return a string based on parameter supplied to it? If so, how?
3. Can I use case...when clause (or similar like in sql) in my SOQL? If so, how can I do so?
 
Thanks