Updating ProcessState in BPM

Hi
What would be the right code to update the process state in the process model where the processState is an Enum field (Int)?

Here is my code that needs fine-tune:

import com.myapp.entity.proc.BidPriceQuoteComparative

def em = persistence.getEntityManager()
def e = em.find(BidPriceQuoteComparative.class, entityId)
e.setProcessState(60)

I am getting this error:

MissingMethodException: No signature of method: com.myapp.entity.proc.BidPriceQuoteComparative.setProcessState() is applicable for argument types: (Integer) values: [60]
Possible solutions: setProcessState(com.myapp.entity.ProcessState), getProcessState()

Hi,
you should probably pass the ProcessState enum value to the setProcessState method, e.g.

e.setProcessState(ProcessState.STARTED);

Tried (changed the code and deployed) and not working.

Here is the exception

    com.haulmont.cuba.core.global.RemoteException:
---
org.activiti.engine.ActivitiException: problem evaluating script: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: ProcessState for class: Script1
---
javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: ProcessState for class: Script1
---
javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: ProcessState for class: Script1
---
groovy.lang.MissingPropertyException: No such property: ProcessState for class: Script1
	at com.haulmont.cuba.core.sys.ServiceInterceptor.aroundInvoke(ServiceInterceptor.java:129)
	at sun.reflect.GeneratedMethodAccessor2306.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644)
	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:633)

Here is my Entity (Partial):

   @Column(name = "PROCESS_STATE")
protected Integer processState;


public void setProcessState(ProcessState processState) {
    this.processState = processState == null ? null : processState.getId();
}

public ProcessState getProcessState() {
    return processState == null ? null : ProcessState.fromId(processState);
}

Here is the groovy code in the BPM as you suggested.

    import com.company.entity.proc.BidPriceQuoteComparative
def em = persistence.getEntityManager()
def e = em.find(BidPriceQuoteComparative.class, entityId)
e.setProcessState(ProcessState.APPROVED)

Here is my Enum

public enum ProcessState implements EnumClass<Integer> {

    NOT_STARTED(10),
    APPROVAL_IN_PROGRESS(20),
    RETURNED_FOR_CORRECTION(30),
    CANCELLED(40),
    REJECTED(50),
    APPROVED(60);

    private Integer id;

    ProcessState(Integer value) {
        this.id = value;
    }

    public Integer getId() {
        return id;
    }

    @Nullable
    public static ProcessState fromId(Integer id) {
        for (ProcessState at : ProcessState.values()) {
            if (at.getId().equals(id)) {
                return at;
            }
        }
        return null;
    }
}

Any clue and suggestions?

import the ProcessState state class in your script or add a package name in the setProcessState method:

import com.company.entity.ProcessState

or

e.setProcessState(com.company.entity.ProcessState.APPROVED)

YES! worked. Thank you