• kenf
  • NEWBIE
  • 85 Points
  • Member since 2009

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 10
    Replies

Hi,

 

I had a requirement to automatically insert/update Contact when a new lead comes in. So, I wrote a before update trigger. Everything worked great, but I need the lead to get into "Converted" state once I have the trigger finish its job. Is there any way to mark it as Converted inside the trigger code?

Hello,

Is there any way to add lead into queue by APEX?

I didn't find any information about how lead queue is implemented

I am consuming a java web service in Apex that needs a security hash computed using MD5 or SHA1, and the digest produced by the Crypto class is not matching the output of the Java algorithm for either method. Here is the Apex code, which I have broken up into several lines in order to print interim debug information:

 

public static String createHash(String preHashValue) {

System.debug('Prehashvalue: ' + preHashValue);

 

Blob bPrehash = Blob.valueOf(preHashValue);

System.debug('\n----Blob.valueOf(preHashValue): ' + bPrehash.toString());

 

String convertedPrehash = EncodingUtil.convertToHex(bPrehash);

System.debug('\nHex prehash value: ' + convertedPrehash);

 

Blob bHexPrehash = Blob.valueOf(convertedPrehash);

System.debug('\nBlob.valueOf(convertedPrehash): ' + bHexPrehash.toString());

 

Blob bsig = Crypto.generateDigest('SHA1', bHexPrehash);

System.debug('\n--------Blob version of digest: ' + bsig.toString());

 

String result = EncodingUtil.convertToHex(bsig);

System.debug('\n--------------Hex digest value: ' + result);

 

return result;

}

 

And the corresponding Java code:

 

private static String CreateHash(String preHashVal) {

java.security.MessageDigest algorithm;

String md5val = null;

try {

// algorithm = java.security.MessageDigest.getInstance("MD5");

algorithm = java.security.MessageDigest.getInstance("SHA1");

byte[] defaultBytes = preHashVal.getBytes();

System.out.println("Prehash value as bytes: '" + bytesToHexString(defaultBytes) + "'");

 

algorithm.reset();

algorithm.update(defaultBytes);

 

byte[] messageDigest = algorithm.digest();

System.out.println("Computed digest: '" + bytesToHexString(messageDigest) + "'");

 

StringBuffer hexString = new StringBuffer();

 

for (int i = 0; i < messageDigest.length; i++) {

String hex = Integer.toHexString(0xFF & messageDigest[i]);

if (hex.length() == 1) {

hexString.append('0');

}

hexString.append(hex);

}

md5val = hexString.toString();

} catch (Exception e) {

e.printStackTrace();

}

return md5val;

}

 

 

 

Using the same "prehashvalue", which is just a constant, a secret code and a random number, they produce the same values in the log output until Crypto.generateDigest('SHA1', bHexPrehash)  and algorithm.digest().

 

Since neither of these methods has a lot of flexibility in terms of options, I have no idea how to get the hash to work out on both sides. Also, the Java side is code I do not control. I would be truly obligated for your help if you can spot where I have made a mistake.

 

--k 

Message Edited by kenf on 11-11-2009 01:28 PM
Message Edited by kenf on 11-11-2009 01:32 PM
  • November 11, 2009
  • Like
  • 0

Hi,

 

I am not much expert in Web Service concepts(infact am a newbie), want some help in this zone.

 

I have the following requirement at high level :-

 

- An online Quote is created for a contract and is passed from Salesforce to external system say "Ext" via button click from Salesforce Quote record. I think this can be done via Web Service, right?

- From the External System, some attributes and parameters are processed and passed onto the Salesforce as arguments or something. Can anyone tell me how is this possible? I know this is possible but dont know exactly how will it do

- The main question of my post is this -> I want the data string / arguments passed in Salesforce and I just want it as a view page with the data, I dont want the data to be stored somewhere in Salesforce. Can anyone tell me how is this possible? Just want View Data not data to be stored.

 

Please assist.

 

 

Thanks,

 

Vimal

I am consuming a java web service in Apex that needs a security hash computed using MD5 or SHA1, and the digest produced by the Crypto class is not matching the output of the Java algorithm for either method. Here is the Apex code, which I have broken up into several lines in order to print interim debug information:

 

public static String createHash(String preHashValue) {

System.debug('Prehashvalue: ' + preHashValue);

 

Blob bPrehash = Blob.valueOf(preHashValue);

System.debug('\n----Blob.valueOf(preHashValue): ' + bPrehash.toString());

 

String convertedPrehash = EncodingUtil.convertToHex(bPrehash);

System.debug('\nHex prehash value: ' + convertedPrehash);

 

Blob bHexPrehash = Blob.valueOf(convertedPrehash);

System.debug('\nBlob.valueOf(convertedPrehash): ' + bHexPrehash.toString());

 

Blob bsig = Crypto.generateDigest('SHA1', bHexPrehash);

System.debug('\n--------Blob version of digest: ' + bsig.toString());

 

String result = EncodingUtil.convertToHex(bsig);

System.debug('\n--------------Hex digest value: ' + result);

 

return result;

}

 

And the corresponding Java code:

 

private static String CreateHash(String preHashVal) {

java.security.MessageDigest algorithm;

String md5val = null;

try {

// algorithm = java.security.MessageDigest.getInstance("MD5");

algorithm = java.security.MessageDigest.getInstance("SHA1");

byte[] defaultBytes = preHashVal.getBytes();

System.out.println("Prehash value as bytes: '" + bytesToHexString(defaultBytes) + "'");

 

algorithm.reset();

algorithm.update(defaultBytes);

 

byte[] messageDigest = algorithm.digest();

System.out.println("Computed digest: '" + bytesToHexString(messageDigest) + "'");

 

StringBuffer hexString = new StringBuffer();

 

for (int i = 0; i < messageDigest.length; i++) {

String hex = Integer.toHexString(0xFF & messageDigest[i]);

if (hex.length() == 1) {

hexString.append('0');

}

hexString.append(hex);

}

md5val = hexString.toString();

} catch (Exception e) {

e.printStackTrace();

}

return md5val;

}

 

 

 

Using the same "prehashvalue", which is just a constant, a secret code and a random number, they produce the same values in the log output until Crypto.generateDigest('SHA1', bHexPrehash)  and algorithm.digest().

 

Since neither of these methods has a lot of flexibility in terms of options, I have no idea how to get the hash to work out on both sides. Also, the Java side is code I do not control. I would be truly obligated for your help if you can spot where I have made a mistake.

 

--k 

Message Edited by kenf on 11-11-2009 01:28 PM
Message Edited by kenf on 11-11-2009 01:32 PM
  • November 11, 2009
  • Like
  • 0

Hello!  I'm new to Salesforce Development.  I've been asked to display only the first 250 characters of a field.

 

If I try

 

 <apex:outputField value="{!LEFT(item.Description,250)}" />

 

I get the error
Incorrect parameter for function LEFT(). Expected Text, received Object

 

If I try

 

  <apex:outputText value="{!LEFT(item.Description,250)}" />

 

I don't get any errors but all of my whitespace is gone, rendering the field unreadable.  

 

item.Description is a textarea.  

 

Any advice is appreciated.  Thanks!

  • November 10, 2009
  • Like
  • 0

Hi,

 

I had a requirement to automatically insert/update Contact when a new lead comes in. So, I wrote a before update trigger. Everything worked great, but I need the lead to get into "Converted" state once I have the trigger finish its job. Is there any way to mark it as Converted inside the trigger code?

Hi All,
 
I have been trying to use the following HTML code in my VisualForce Page editor.
 

 

Code:
<apex:page controller="Rephome" sidebar="false" tabstyle="SPA_Detail__c" standardstylesheets="false">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<!--[if lt IE 8]><link rel="stylesheet" type="text/css" href="{!$Resource.ie}" /> <![endif]-->
<!--[if lt IE 7]> <link rel="stylesheet" type="text/css" href="{!$Resource.ielt7}" /> <![endif]-->

My questions:

Is it possible to use DOCTYPE defenition?, i get a warning saying that DOCTYPE is not allowed.

The conditional IF statements are finally generated as comments. Is HTML Conditional IF statement not supported in VisualForce or is there some other way in which this can be achieved?

I face browser related issues while rendering the VisualForce, is it because of the Doctype? When a custom stylesheet is used for a VF page with Salesforce Header does the custom stylesheet affect the Salesforce Header as well.

Thanks,

Edwin
 

Hi All,

I have to use the following doctype in my visualforce page. How do i do this?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

Thanks,
Edwin

Hello,

Is there any way to add lead into queue by APEX?

I didn't find any information about how lead queue is implemented