It seems Defined function doesn't works

Hi, I was trying to do our functions for Toolbar and I could see that it doesn’t works.

In the framework I can find the table with the functions and it’s full.

[attachment=2]tabla.png[/attachment]

And this is the line who you get the foundset but you don’t get nothing and I think it’s the problem.

[attachment=1]linea.png[/attachment]

When we use the option “Toolbar function” all it’s ok, the problem is on “Defined function”

[attachment=0]file.png[/attachment]

Can you help me to fixed this?

Thank you in advance!!!

I just tested this function in the frameworks and it works fine. If in your case svy_nav_callFunction cannot get a foundset, what is the value of globals.nav_db_framework at that moment?

I’m making some more tests, but i can see the _function_id is not passed in the function callFunction in line 364 of the svy_nav_fr_toolbar_base.js:

/**
 * Calls the framework function
 * @param {JSEvent} _event
 * @param {String|UUID} _function_id
 *
 * @properties={typeid:24,uuid:"48A3E15B-CFC3-44A1-9F1B-99697B90797C"}
 */
function callFunction(_event, _function_id) {
	globals.svy_nav_callFunction(_function_id)
}

and i don’t know why is it null

I think you will need a support websesion to look why this is happening.

Only say, that I can’t see when fill the field _function_id, in all framework I only can find this:

[attachment=0]1.png[/attachment]

And, when you filter for _function_id when the function is called in the toolbar is null, and for this cause we can’t execute our functions.

Hi pentamsi,

My collegue just told me he had made a fix for your problem. If you replace the method updateUI() of the form ‘svy_nav_fr_toolbar_base’ with the following it should be ok.

/**
 * @param {String} [_mode]
 * 
 * @properties={typeid:24,uuid:"A88C66C9-D966-47D1-A890-A039386432A9"}
 */
function updateUI(_mode) {
	
	if(_mode)
	{
		vMode = _mode
	}
	
	/** @type{Array<{name:String, alignment:Number}>} */
	var _toolbar = getToolbarItems(vProgram, 'tab')
	if (!_toolbar) {
		return;
	}
	
	/** @type{Array<{function_type:Number, function_id:Number, image_url:String, flag_splitter:Number, toolbar_function:String, parent_id:String}>} */
	var _items;

	var _formName, _jsForm;

	var _iconHeight = getIconHeight();
	var _iconWidth = getIconWidth();
	var _spacing = getSpacing();
	var _formWidth, _x;
	
	if(!vInit)
	{
		
		var _formAr = []; //array of all toolbar form names
		for (var i = 0; i < _toolbar.length; i++) {
			//loop through toolbars
			if (_formName != getToolbarForm(_toolbar[i].name)) {
				_formName = getToolbarForm(_toolbar[i].name); //the toolbarForm can change for each toolbar (when having toolbars with multiple tabs)
				forms[_formName]["vLeftOffset"] = getLeftOffset();
				forms[_formName]["vRightOffset"] = getRightOffset();
			}
			if (_formAr.indexOf(_formName) == -1) {
				_formAr.push(_formName);
			}
	
			_jsForm = solutionModel.getForm(_formName);
			_formWidth = _jsForm.width;
			
			_items = _toolbar[i].items
			var _jsMethod, _jsLabel;
			for (var j = 0; j < _items.length; j++) {
				
				//button for main form but form is tab, or button is for tab but form is main
				if((vPanel != 1 && _items[j].access_type == 'M') || (vPanel == 1 && _items[j].access_type == 'T')) continue
				
				//This item is the child of another item. It will not be shown as a button, but for example in a popup.
				if (_items[j].parent_id) continue;
				
				// loop through items
				if (_items[j].function_type == 1) {
					_jsMethod = _jsForm.getMethod("callProgramFunction");
					_jsMethod = solutionModel.wrapMethodWithArguments(_jsMethod, [null, '"' + _items[j].toolbar_function + '"']);
				} else if (_items[j].function_type == 2) {
					_jsMethod = _jsForm.getMethod("callFunction");
					_jsMethod = solutionModel.wrapMethodWithArguments(_jsMethod, [null, '"' + _items[j].function_id + '"']);
				}
				//Determine x position and update offset for next item
				if (_toolbar[i].alignment == 1) {
					_x = forms[_formName]['vLeftOffset'];
					forms[_formName]['vLeftOffset'] = forms[_formName]['vLeftOffset'] + _iconWidth + _spacing
				} else {
					_x = (_formWidth - forms[_formName]['vRightOffset'] - _iconWidth);
					forms[_formName]['vRightOffset'] = forms[_formName]['vRightOffset'] + _iconWidth + _spacing
				}
				_jsLabel = _jsForm.newLabel('', _x, forms[_formName].getTopOffset(), _iconWidth, _iconHeight, _jsMethod);
				_jsLabel.imageMedia = solutionModel.getMedia(_items[j].image_url);
				_jsLabel.name = _items[j].toolbar_item_id
				_jsLabel.showClick = false;
				_jsLabel.rolloverCursor = SM_CURSOR.HAND_CURSOR
				_jsLabel.toolTipText = _items[j].description
				_jsLabel.transparent = true;
				
				if ((_items[j].mode_type && _items[j].mode_type.indexOf(vMode) >= 0) || _items[j].mode_type == 'all') {
					_jsLabel.enabled = true
				} else {
					_jsLabel.enabled = false
				}
				_jsLabel.anchors = _toolbar[i].alignment == 1 ? SM_ANCHOR.NORTH|SM_ANCHOR.WEST : SM_ANCHOR.NORTH|SM_ANCHOR.EAST;
	
				//set rightClick
				if (_items[j].function_type_r == 1 && _items[j].toolbar_function_r) {
					_jsMethod = _jsForm.getMethod("callProgramFunction");
					_jsMethod = solutionModel.wrapMethodWithArguments(_jsMethod, [null, '"' + _items[j].toolbar_function_r + '"']);
					_jsLabel.onRightClick = _jsMethod
				} else if (_items[j].function_type_r == 2 && _items[j].function_id_r) {
					_jsMethod = _jsForm.getMethod("callFunction");
					_jsMethod = solutionModel.wrapMethodWithArguments(_jsMethod, [null, '"' + _items[j].function_id_r + '"']);
					_jsLabel.onRightClick = _jsMethod
				}
				
				forms[_formName]['vOffset'] = forms[_formName]['vOffset'] + _iconWidth + _spacing;
				
				if(_items[j].flag_splitter)
				{
					draw_splitter(_jsForm, _toolbar[i].alignment, _spacing);
				}
			}
		}
		
		//call recreateUI for all changed forms 
		for (var n = 0; n < _formAr.length; n++) {
			forms[_formAr[n]].controller.recreateUI();
		}
		vInit = 1
	}
	else //only update the layout
	{
		var _val, _method;
		for (var k = 0; k < _toolbar.length; k++) {
			_formName = getToolbarForm(_toolbar[k].name)
			_items = _toolbar[k].items
			for (var m = 0; m < _items.length; m++) {
				if (_items[m].parent_id) continue;
					
				_val = false;
				//if the current mode is in the string of modes that is allowed for this item
				if (_items[m].mode_type && _items[m].mode_type.indexOf(vMode)>= 0) {
					_val = true
				}
				if (_items[m].function_type == 1) {
					_method = _items[m].toolbar_function;
				} else {
					_method = _items[m].function_id;
				}
				if (forms[_formName].elements[_items[m].toolbar_item_id]) {
					var _aloud = _val && isMethodAllowed(_method)
					if(forms[_formName].elements[_items[m].toolbar_item_id].enabled != _aloud)
					{
						forms[_formName].elements[_items[m].toolbar_item_id].enabled = _aloud;
					}
				}
			}
		}
	}
}

Hi!!!

With the fix all works fine, thank you a lot for quickly and attention.