Damn, you seem to be correct, documentation of the variable scope while using cshs is quite limited. When using CSHS:es, only outside of the coach block can use the tw.local scope. This is a safety feature though, to prevent users from accessing variables unless you have explicitly stated they should be accessible. Only blocks that can be bound to data can be accessed.
I've used the product since 2016, so since IBM BPM 8.5.5 i've been coding in it.
Regarding adding functions that are reusable inside coaches, the simplest way i've found of doing this is:
Create a custom View, and add the function within its load event. For example if you want to create a function to add the value from two components, here i have a function with a delayed fire of 2.7 seconds. ControlId is entered, and a function similar to the earlier i linked is used
The logic for the c
this.myFunc = function (input, input2) {
var _this = this;
setTimeout(function(){
_this.internalMyFunction(input, input2);
}, 2700);
}
Then add the view to your coach, and to call it use ${MyControlId}.myFunc();
However, what we mostly end up doing to get reusable functions, is create snippets, add them to a shareable site such as GIT or Confluence, and copy paste the functions to CustomHTML-scripts in the coaches instead. Since most projects will need to make minor adjustments anyway
------------------------------
Johan Andersson
------------------------------
Original Message:
Sent: Wed April 17, 2024 12:18 PM
From: Mike Prentice
Subject: Coach Programming 101 Information
Thank you Johan. The Redbook mentioned, yes, I have been using that. It does seem what I am looking for does not really exist, without paying someone to offer it. I assumed that might be an option, but as a last resort.
For example, how/where do you know that tw.object can't be accessed in a Coach View? The documentation, unless on some obscure page, does not state that, in fact it states tw is accessible everywhere.
I know I am complicating this some by wanting to create a toolkit as we have a common feature we wanted to build once for a couple of projects, so I need to pass into it a couple of key variables. Thus, understanding what exists, when it exists, and all that. The Redbook and some other articles are not bad at explaining state, but there is still an element of basic knowledge that is missing and not explained anywhere. It seems you either know the product because you knew Lomadri way back or do not.
------------------------------
Mike Prentice
Original Message:
Sent: Mon April 15, 2024 07:34 PM
From: Mike Prentice
Subject: Coach Programming 101 Information
I am trying to get a couple of new developers up to speed in BAW Coach programming, all the tw objects and syntax and such. So many articles are years old and even then I find find the initial, basic stuff. Like I want to add a little JS code in a coach UI, who to reference the TW object. They are getting errors of ts does not exist sort of errors. Appreciate in advance any information this group might have.
Thank you.
------------------------------
Mike Prentice
------------------------------