I have a string json in my camunda variable like this [{“roleCode”:“OWNE”,“roleName”:“Người vay”,“perName”:“AAA”,“nationalityCode”:“VIETNAM”,“nationalityName”:“AAA”,“startDate”:null,“endDate”:null,“identityType”:null,“content”:null}]
then in my bpmn model in node service task I use groovy script inline to get it
def json = execution.getVariable(“GeneralCriteriaCountryNationJson”)
then I convert it to json using spin put to camunda variable as type json
def v = Spin.JSON(json)
then I override GeneralCriteriaCountryNationJson variable with execution.setVariable(“GeneralCriteriaCountryNationJson”, v)
when I check in camunda GeneralCriteriaCountryNationJson still type string not json but when I change execution.setVariable(“GeneralCriteriaCountryNationJson2”, v) new variable will set as json type. Is any way to fix this problem thanks.
Hello my friend!
I believe this happens because Camunda still keeps a reference to the previously created variable.
One thing that might help you is…
Instead of creating a new variable, you can remove the variable and then recreate it again.
example:
def json = execution.getVariable(“GeneralCriteriaCountryNationJson”);
def v = Spin.JSON(json);
execution.removeVariable("GeneralCriteriaCountryNationJson");
execution.setVariable("GeneralCriteriaCountryNationJson", v);
I hope this helps!
William Robert Alves
NOTE:
If you were using JavaScript in your script, I believe this behavior would be different, and the type of the variable would also be overwritten when overwriting the variable… I’m not sure, but you can do some tests, because as far as I remember, I’ve had problems similar to yours.
William Robert Alves
Thanks for reply. I figured out my situation. I forgot that in the next step I had set this variable again. So it my bad