BPM, Workflow, and Case

  • 1.  Uncertain behavior when setting content object at process layer

    Posted Tue June 29, 2021 08:05 AM
    Hi,
    I am currently workin on BAW v20.0.1 to create a case solution having activities implemented in bpm processes. I use script to initialize content object/case properties properties inside bpm process, however I have a noticed this initialization does not change the variables sometimes. The behavior is very uncertain. 
    Ultimately I had to move this code to service layer and use to make sure properties are initialized correctly everytime
    tw.system.currentProcessInstance.parentCase.setCasePropertyValues


    Has anyone else faced this issue? Is it a bug in the product?

    Regards,
    Jyoti


    ------------------------------
    Jyoti Korde
    ------------------------------


  • 2.  RE: Uncertain behavior when setting content object at process layer

    Posted Wed June 30, 2021 06:11 AM
    Edited by Massimiliano Carra Wed June 30, 2021 06:11 AM
    Hi Jyoti,
    the method you used should work.
    As an alternative you can also set (or get) the value of the case properties using the local variables automatically defined in the activity's process:
    tw.local.caseProperties.propertyName.value
    where propertyName is the name of the property defined in your case.

    Hope it helps.

    ------------------------------
    Massimiliano Carra
    ------------------------------



  • 3.  RE: Uncertain behavior when setting content object at process layer

    Posted Fri September 03, 2021 07:56 AM
    Don't know if this is related, but I was experimenting and observe that setting (initializing from null) tw.local.caseProperties.MyVariable.value in a process activity post-assignment normally works. However: This is a subactivity in a container activity with a sibling manual subactivity. If I disable the manual subactivity before completing the first subactivity, that case property is not set. More precisely, it is set in the process instance (visible in process inspector), but not when viewing the case details in the navigator. The change does not cascade. I should add that disabling the manual subactivity means that the case is complete.

    ------------------------------
    Mattias Edling
    ------------------------------



  • 4.  RE: Uncertain behavior when setting content object at process layer

    Posted 24 days ago
    Edited by Mattias Edling 24 days ago
    I think I also have this problem, but in 21.0.2 on-premise and on the service level. I want to set case properties from within a service flow which has retrieved values elsewhere.

    (Using a process level script would clutter the business process diagram and possibly require additional process variables. Mapping directly from the task output to tw.local.caseProperties.BusinessName etc would prevent running, debugging and testing the process without a parent case.)

    if (tw.system.currentProcessInstance != null) {
    	if (tw.system.currentProcessInstance.parentCase != null) {
    		//DEBUG Set seems unreliable. Try to log Get first.
    		var propertyNamesToGet = [];
    		propertyNamesToGet[0] = "MESBX_BusinessName";
    		var propertyValuesToLog = tw.system.currentProcessInstance.parentCase.getCasePropertyValues(propertyNamesToGet);
    		log.info("MESBX - Current value of case property  " + propertyNamesToGet[0] + " is: " + propertyValuesToLog[0]);
    		
    		var propertyNames = [];
    		var propertyValues = [];
    		propertyNames[0] = "MESBX_BusinessName";
    		propertyValues[0] = "MOCKED BusinessName in Retrieve and Map TS: " + tw.local.identifier;
    		propertyNames.push("MESBX_ContactPerson");
    		propertyValues.push("MOCKED ContactPerson in Retrieve and Map TS: " + tw.local.identifier);
    		tw.system.currentProcessInstance.parentCase.setCasePropertyValues(propertyNames, propertyValues, false);
    		log.info("MESBX - Tried updating case properties: " + propertyValues[0] + " - " + propertyValues[1]);
    	}
    	else {
    		log.info("MESBX - No parent case to uodate properties for.");
    	}
    }​

    This is my log output. Neither values, nor any errors, when using getCasePropertyValues and setCasePropertyValues. The two last lines are generated from a process script. The BusinessName property has retained its initial value from the add case page, before entering the process:

    [11/4/21 11:14:13:509 CET] 000001c6 LoggerScripta I   MESBX - Current value of case property  MESBX_BusinessName is: 
    [11/4/21 11:14:13:522 CET] 000001c6 LoggerScripta I   MESBX - Tried updating case properties: MOCKED BusinessName in Retrieve and Map TS: {1071EA7C-0000-CA1A-9011-42C904C90BC4} - MOCKED ContactPerson in Retrieve and Map TS: {1071EA7C-0000-CA1A-9011-42C904C90BC4}
    [11/4/21 11:26:42:620 CET] 000001ca LoggerScripta I   MESBX - process Review Application FINALIZE - caseId is: {1071EA7C-0000-CA1A-9011-42C904C90BC4}
    [11/4/21 11:26:42:620 CET] 000001ca LoggerScripta I   MESBX - process Review Application FINALIZE - tw.local.caseProperties.BusinessName.value is: Overwrite Me 2 AB




    ------------------------------
    Mattias Edling
    ------------------------------



  • 5.  RE: Uncertain behavior when setting content object at process layer

    Posted 24 days ago

    OK, I should not have tried to be l33t by using ordinary javascript arrays (allowing push() instead of direct element access). When using TW objects it worked ... 

    var propertyNames = new tw.object.listOf.String();
    var propertyValues = new tw.object.listOf.String();

    I also found this recipe where the method is used in a process script, but thankfully it works from service flow scripts as well!

    https://community.ibm.com/community/user/automation/blogs/massimiliano-carra/2021/09/24/recipe-design-business-workflow-case-bpmn



    ------------------------------
    Mattias Edling
    ------------------------------