multi row variable set and functions from onLoad catalog client scripts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2020 08:16 AM
In my catalog Item I have a catalog client script that is configured as an onLoad (non isolated) and will load a function I can use throughout the catalog item on any item variables or any variables in the variable sets. all pretty standard
I have added a MRVS to this catalog item but it cannot use the function from the catalog client script, complains it is not defined
Is this possible or do I need to write the routine into the MVRS itself ? (annoying as there could then be 2 sets of code to maintain)
The code is
function onLoad() {
}
updateIsError = function() {
// do something
}
and the error in the MVRS is
Just wonder if I am missing a trick here - such as a variable set attribute - as the function is available to all of the other variable and variable sets in the item. I guess the modal maybe getting in the way, but why would its own client scripts work ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2020 03:27 AM
OK, so there is a way to do this, but now there is something new
So, in your catalog item you have an onLoad catalog client script with this
function onLoad() {
}
updateIsError = function(strField) {
// do something
g_form.showFieldMsg(strField,'Hi','info');
}
In any other catalog client script that is associated to this catalog item (on the item itself or an associated variable set), you can call
updateIsError('variable_name');
And it will perform whatever is in that function and add a field msg to the variable "variable_name"
If you want to do this from an MRVS, use the following line
window.parent.updateIsError('variable_name');
That works, but if your function does what my example above does which is try to use a g_form.setFieldMsg it will throw an error in the console as it cannot find the field.
In this scenario I see I have three choices.
- Create a new version for the main item using g_form.showFieldMsg and another for MRVS that uses alert
- Modify the code to add so any showFieldMsg are performed by a function. If that function fails on the g_form.showFieldMsg it reverts to an alert instead.
- See if there is anyway that I can set a FieldMsg on the dialog and trap any error messages