Hi
I need to update a user custom info value using a groovy script after a task did complete.
I have a script task, befor end process and after the main task. Inside a script task there is a Script connector with this code inside:
import org.bonitasoft.engine.api.CustomUserInfoAPI
import org.bonitasoft.engine.identity.CustomUserInfoValue
CustomUserInfoAPI customInfo;
return customInfo.setCustomUserInfoValue(106, 301, "78");
Where: 106 is the Definition Id of the custom info. 301 is the User Id, and 78 is the value to update.
So, when a run the task this is the error log:
021-02-02 11:24:14.681 -0300 INFORMACIÓN: org.bonitasoft.engine.api.impl.ProcessStarter THREAD_ID=109 | HOSTNAME=CRISTIAN | TENANT_ID=1 | The user <remoncristian> has started the process instance <75004> of process <probar rest custom API> in version <1.0> and id <4786766726863350203>
2021-02-02 11:25:56.550 -0300 INFORMACIÓN: org.bonitasoft.engine.api.impl.ProcessAPIImpl THREAD_ID=118 | HOSTNAME=CRISTIAN | TENANT_ID=1 | The user <remoncristian> has executed the task [name = <Tarea1>, display name = <Tarea1>, id = <1460024>, parent process instance = <75004>, root process instance = <75004>, process definition = <4786766726863350203>] with task inputs: {diasPendientes=22}
2021-02-02 11:25:57.429 -0300 GRAVE: org.bonitasoft.engine.execution.work.InSessionBonitaWork THREAD_ID=184 | HOSTNAME=CRISTIAN | TENANT_ID=1 | The work [ExecuteConnectorOfActivity: flowNodeInstanceId = 1460024, connectorDefinitionName = setDiasPendientes] failed. The failure will be handled.
2021-02-02 11:25:57.437 -0300 GRAVE: org.bonitasoft.engine.execution.work.InSessionBonitaWork THREAD_ID=184 | HOSTNAME=CRISTIAN | TENANT_ID=1 | org.bonitasoft.engine.commons.exceptions.SBonitaRuntimeException : "java.lang.NullPointerException: Cannot invoke method setCustomUserInfoValue() on null object"
org.bonitasoft.engine.commons.exceptions.SBonitaRuntimeException: java.lang.NullPointerException: Cannot invoke method setCustomUserInfoValue() on null object
at org.bonitasoft.engine.connector.impl.ConnectorExecutorImpl.lambda$execute$0(ConnectorExecutorImpl.java:155)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException: Cannot invoke method setCustomUserInfoValue() on null object
at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:91)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:47)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:34)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:144)
at Script1.run(Script1.groovy:13)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:574)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:612)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:583)
at org.bonitasoft.connectors.scripting.GroovyScriptConnector.executeBusinessLogic(GroovyScriptConnector.java:48)
at org.bonitasoft.engine.connector.AbstractConnector.execute(AbstractConnector.java:77)
at org.bonitasoft.engine.core.connector.impl.SConnectorAdapter.execute(SConnectorAdapter.java:73)
at org.bonitasoft.engine.connector.impl.ConnectorExecutorImpl$ExecuteConnectorCallable.call(ConnectorExecutorImpl.java:253)
at org.bonitasoft.engine.connector.impl.ConnectorExecutorImpl$ExecuteConnectorCallable.call(ConnectorExecutorImpl.java:212)
at org.bonitasoft.engine.connector.impl.ConnectorExecutorImpl.lambda$wrapForStats$1(ConnectorExecutorImpl.java:164)
at org.bonitasoft.engine.connector.impl.ConnectorExecutorImpl.lambda$execute$0(ConnectorExecutorImpl.java:152)
... 4 more
Thanks for the help!
Cristian