I'm calling a remoting method from javascript. The method expects a custom class with one of the fields of type ConnectApi.MarkupType.

While sending a string value for this field, I'm getting an error Unexpected type for Controller.methos(CustomClass)

How do I send the enum value from frontend?

1 Answer 1


Passing the string representation - the name - should work:

private static Map<String, ConnectApi.MarkupType> MT_MAP {
    get {
        if (MT_MAP == null) {
            MT_MAP = new Map<String, ConnectApi.MarkupType>();
            for (ConnectApi.MarkupType v : ConnectApi.MarkupType.values()) {
                MT_MAP.put(v.name(), v);
        return MT_MAP;

public static void methos(String mts) {

    ConnectApi.MarkupType mt = MT_MAP.get(mts);

  • It's oddly specific that you can return an enum value but not accept an enum parameter, despite the fact it compiles.
    – sfdcfox
    Sep 6, 2018 at 10:32

You must log in to answer this question.

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