-1

I am creating a screen flow with a http callout. First the screen captures a few fields from the user, then it makes a http callout to send the info captured as parameters to a remote site. Among the other http parameters, I also need to include a "signature" as a parameter that is a MD5 checksum of all user entered data. Essentially, I need to make the following function call:

EncodingUtil.convertToHex(Crypto.generateDigest('MD5', str))

where str is a concatenation of all user entered parameters. Is this possible?

1 Answer 1

0

To call a method, you use an Invocable Method. That might look like this:

public class GenerateDigest {
  public class Request {
    @InvocableVariable(required=true)
    public String str;
  }
  public class Response {
    public Response(String digest) {
      this.digest = digest;
    }
    @InvocableVariable
    public String digest;
  }
  @InvocableMethod(label='Generate Digest' description='Generates an MD5 digest.')
  public static Response[] generateDigests(Request[] inputs) {
    Response[] outputs = new Response[0];
    for (Request input : inputs) {
      outputs.add(
        new Response(
          EncodingUtil.convertToHex(Crypto.generateDigest('MD5', input.str))
        )
      );
    }
    return outputs;
  }
}

Then, you can map the input from an flow variable, and assign the output to another Flow variable. After that, you can use that digest any way you'd like.

1
  • Thank you for your time and patience answering my newbie questions! Aug 29 at 22:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .