BPM, Workflow, and Case

BPM, Workflow, and Case

Come for answers. Stay for best practices. All we’re missing is you.

 View Only
Expand all | Collapse all

How to create "Environment Variables" on IBM Case Manager 5.3.3 ?

  • 1.  How to create "Environment Variables" on IBM Case Manager 5.3.3 ?

    Posted Wed July 12, 2023 12:50 PM

    Hi

    Can someone help me with some information or documentation on how to create  "Environment Variables" on IBM Case Manager 5.3.3 ?

    I need to create variables that can be stored once and be called from the javascript inside a "Script Adapter".

    Thanks in advance.



    ------------------------------
    Martin Iturbide
    Consultant
    Next Step C.A.
    Quito
    ------------------------------


  • 2.  RE: How to create "Environment Variables" on IBM Case Manager 5.3.3 ?

    Posted Thu July 13, 2023 11:08 AM

    Have you looked into dojo's lang.setObject (to create variables / functions) from one place / script adapter and then use lang.getObject to read them back from another?

    I use this technique to externalize common functions and variables within a solution that can then be shared across multiple pages.

    If you are talking about sharing variables across multiple script adapters in the same page then there is an alternative approach where you send all events through the same script adapter

    Here's a code snippet showing use of getObject() and combining all of your into a single script adapter:

    // connect all incoming events to this single script adapter
    try {
        require(["dojo/_base/lang"], function(lang){

            var self = this;
            
            // check the event name to see which bit of code needs to run
            if (payload.eventName === "icm.FieldUpdated") {
                // call a global function that you previously added to the DOM. you can even reference variables/constants as parameters
                lang.getObject("my.namespace.functions.CaseFieldUpdated")(self,payload,lang.getObject("my.namespace.functions.CONSTANTS.MODELSCOPE.CASE"));

                // or you can save a variable into the current object using self
                self.myVariable = "Hello World";
            }
            // check the event name to see which bit of code needs to run
            else if (payload.eventName === "icm.custom.UpdateAddressContact") {
                // call another global function
                lang.getObject("my.namespace.functions.UpdateAddress")(self,payload);
                // and reference the value in myVariable
                if(self.hasOwnProperty('myVariable')){
                    alert (self.myVariable);
                }
            }
        });
    }
    catch (Error) {
        alert ("Source Module: " + self.name + "\r\n\r\n"+Error.name+" - "+Error.description+"\r\n"+Error.message);
    }



    ------------------------------
    Dave Ward
    ------------------------------