Parameter Declaration

This is probably a really elementary question, but can someone point me to a reference that can help me understand the parameter declarations of a function? I have warnings all over my js files due to something not being defined in a script.

Thanks for the help!

Here is what I use:

function functionName( parameter1, parameter 2, etc. )
{
    if ( !parameter1 )
    {
        ...code goes here
    }

}

Also, check out the tutorials at W3Schools Online Web Tutorials

If this doesn’t help, post your code and error messages, and someone will help you.

what are exactly your errors do you have a sample code with the warning you get?

Here are some examples of what I’m talking about. I commented the warnings in the code below.

/**
 * @properties={typeid:24,uuid:"2D692FDE-141C-4B8F-9D3D-AD794133FFB4"}
 */
function Batch_Master()
{
	//Declare Variables
	var rowCount;
	var selectedNodes;
	var nextID;
	var row;
	
	forms.Dev_charge_transactions.encounter_id = forms.Ledger_List.encounterID;
	forms.Dev_charge_transactions.ledger_id = forms.Ledger_List.ledgerID;
	forms.Dev_charge_transactions.ledger_charge_id
	forms.Dev_charge_transactions.ledger_code
	forms.Dev_charge_transactions.ledger_type
	forms.Dev_charge_transactions.transaction_amount
	forms.Dev_charge_transactions.transaction_type
	forms.Dev_charge_transactions.transaction_description
	forms.Dev_charge_transactions.transaction_date
	
	// get the selected encounter and add the charge
	selectedNodes = forms.Ledger_List.elements.treeview.getSeletedNodes();   //Warning: The function getSeletedNodes() is undefined in this script
	rowCount = globals.g_Ledger_Tree_DS.getMaxRowIndex();   //Warning: The function getMaxRowIndex() is undefined in this script
	if(selectedNodes.length > 0)
	{
		nextID = rowCount + 1;
		globals.g_Ledger_Tree_DS.addRow([nextID, selectedNodes[0],  utils.dateFormat(new Date(),'MM/dd/yyyy'),  //Warning: The function addRow() is undefined in this script
		                        forms.CPT_Add_Charge_Results.ledger_code, forms.CPT_Add_Charge_Results.description, 'INS',
		                        forms.CPT_Add_Charge_Results.cost, null, (forms.CPT_Add_Charge_Results.fee * units), null, null, null,
		                        dataset.getValue(1,1), forms.CPT_Add_Charge_Results.cpt_code, 'resultset_next.png',false]);
		
		//Update the total charges for the encounter
		row = globals.getRowForId(selectedNodes[0]);
		
	}
}
/**
 * @properties={typeid:24,uuid:"45AF5061-DC5D-4995-836E-8866CC65D16B"}
 */
function onNodeExpanded()
{	
	//Change the width of column 4 when the node is expanded
	elements.treeview.setColumnWidth('column4', 350);   //Warning: The function setColumnWidth() is undefined in this script
	
	//clear selected node because when nodes are expanded the selected node doesn't change correctly
	elements.treeview.setSelectedNodes(null);   //Warning: The function setSelectedNodes() is undefined in this script
	encounterID = null;
	ledgerID = null;
}

In the next example snippet I pass values to a form created in the solution model.

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"C80BB915-3BE3-4086-96E9-61390F916347"}
 */
function Select_Check(event)
{
	//Declare Variables
	var query;
	var dataset;
	var bID = batch_id;
	var bcIns;//Batch check insurance
	var chIns;//charge insurance
	var pressedButton;
	var test;
	
	//Pass the insurances from the batch check and the charge
	bcIns = carrier_code;
	chIns = forms["Charge1"].applicable_ins_code;
	
	//If the insurances don't match, show dialog to confirm whether or not to continue
	if(bcIns != chIns)
	{
		//Dialog
		pressedButton = plugins.dialogs.showQuestionDialog("Insurance Mismatch","The insurance code for the batch check and the primary insurance code for the \
															encounter do not match.","OK","Cancel");
		//If the mismatch is OK
		if(pressedButton === "OK")
		{
			//query to see if unposted_amount is populated for the selected batch
			query = "Select unposted_amount from batch where batch_id = ?";
			dataset = databaseManager.getDataSetByQuery(databaseManager.getDataSourceServerName(controller.getDataSource()),query,[bID],1);
			
			//Pass values to Payment Detail form
			forms["Detail_Body"].batchAmount = check_amount;   //Warning: The property batchAmount is undefined for the type Form
			forms["Detail_Body"].batchCheckNum = check_number;   //Warning: The property batchCheckNum is undefined for the type Form
			forms["Detail_Body"].batchCkIns = carrier_code;   //Warning: The property batchCkIns is undefined for the type Form
			forms["Detail_Body"].batchDate = date_received;   //Warning: The property batchDate is undefined for the type Form
			forms["Detail_Body"].batchID = bID;   //Warning: The property batchID is undefined for the type Form

I know I need to declare strings, numbers, etc like so:

/**
 * @param {JSEvent} event the event that triggered the action
 * @param {String} test1
 * @param {Number} test2
 * 
 * @properties={typeid:24,uuid:"BA550780-2730-456A-A4B9-19009909582A"}
 */
function My_Function(event,test1,test2)
{
}

When you type @param {} and hit Ctrl+Space for code completion between the the brackets({}), the list is quite long. Is there a reference for that list? I want to make sure I’m doing things correctly.I also would like to know when and how to correctly use /** @type {JSComponent}/, /** @type {BaseComponent}/, etc.

Thanks for your help

rowCount = globals.g_Ledger_Tree_DS.getMaxRowIndex(); //Warning: The function getMaxRowIndex() is undefined in this script

What is the type of that global? is it specified as a JSDataset ??

forms["Detail_Body"].batchAmount = check_amount; //Warning: The property batchAmount is undefined for the type Form

If you do it like this then it maps to the default RuntimeForm type
Why aren’t you doing:

forms.Detail_Body.batchAmount = check_amount

Those are all the types there are, JSComponent is a SolutionModel type, and things that start with RuntimeXxxxx are the runtime/ui elements

I don’t know why you get warnigns for these:

elements.treeview.xxxx

that is our DbTreeView bean right?
What happens if you type this: elements.treeview.
and then press cltr-space so code complete this?

Here is the declaration of g_Ledger_Tree_DS. I used the treeview sample to model my treeview, so whatever type was in the sample is what I used.

/**
 * @properties={typeid:35,uuid:"A06B6158-0A4C-42D2-829F-BDAE76615DCD",variableType:-4}
 */
var g_Ledger_Tree_DS;
forms["Detail_Body"].batchAmount = check_amount; //Warning: The property batchAmount is undefined for the type Form

If you do it like this then it maps to the default RuntimeForm type
Why aren’t you doing:

forms.Detail_Body.batchAmount = check_amount

Form Detail_Body is created using the solutionModel:

//clone form Ledger_Payment_Detail_test_Head_Foot
newForm1 = solutionModel.getForm("Ledger_Payments_Detail_Head_Foot");
body = solutionModel.cloneForm("Detail_Body",newForm1);

Is there another way for me to pass values to the variables on Detail_Body? Since the form is created using the solutionModel, forms.Detail_Body.batchAmount = check_amount give me these warnings -
Multiple markers:
-The property Detail_Body is undefined for the type Forms
-The property Detail_Body is undefined for the type Forms

I don’t know why you get warnigns for these:

elements.treeview.xxxx

that is our DbTreeView bean right?
What happens if you type this: elements.treeview.
and then press cltr-space so code complete this?

I use the Servoy TreeView Bean from ServoyForge. When I type elements.treeview. and press cltr-space it tells me there are no completions available. I don’t think I’ve changed anything with the treeview since I installed it using Servoy 5.2. Pretty sure the code completion was working then.

I re-downloaded and imported the servoy_sample_treeview example. It has the same warnings:

/**
 *
 * @properties={typeid:24,uuid:"79a4f55d-7359-4619-b549-b4e25fba793f"}
 */
function getRowForId()
{
	// find the dataset row for the argument id
	for (var i = 2; i <= globals.treeviewDataSet.getMaxRowIndex(); i++)  //Warning: The function getMaxRowIndex() is undefined in this script
	{
		var row = globals.treeviewDataSet.getRowAsArray(i);  //Warning: The function getRowAsArray() is undefined in this script
		if(arguments[0] == row[0])
		{
			return i;
		}
	}
	
	return -1;
}
/**
 *
 * @properties={typeid:24,uuid:"adf1023b-f046-43a7-ad54-3f62a3d22a9e"}
 */
function initTreeview()
{
	elements.treeview.setDataSet(globals.createDataSet());  //Warning: The function setDataSet() is undefined in this script
	//apply css style
	elements.treeview.setStyleSheet(globals.myStyle);
	
	// setup columns size and format
	elements.treeview.setColumnWidth('treeColumn', 250);  //Warning: The function setColumnWidth() is undefined in this script
	elements.treeview.setColumnWidth('column1', 50);  //Warning: The function setColumnWidth() is undefined in this script
	elements.treeview.setColumnWidth('column2', 100);  //Warning: The function setColumnWidth() is undefined in this script
	elements.treeview.setColumnWidth('column3', 200);  //Warning: The function setColumnWidth() is undefined in this script
	elements.treeview.setColumnHeaderTextFormat('column2', '<html><b>$text</b></html>');  //Warning: The function setColumnHeaderTextFormat() is undefined in this script
	elements.treeview.setColumnTextFormat('column3', '<html>$text</html>');  //Warning: The function setColumnTextFormat() is undefined in this script
	elements.treeview.setRowHeight(16);  //Warning: The function setRowHeight() is undefined in this script
	
	// set callback when edit finished
	elements.treeview.onEditFinished(onEditFinished);  //Warning: The function onEditFinished is undefined in this script
	elements.treeview.onNodeClicked(onNodeClicked);  //Warning: The function onNodeClicked is undefined in this script
	
}
/**
 * @properties={typeid:35,uuid:"e44436fc-de66-44ae-b1d2-081d2f9bc0fc",variableType:-4}
 */
var treeviewDataSet;

when using servoy-treeview.jar, that is the stable version, I do not
see any warnings, but I do see them when using servoy-treeview-test.jar,
that is a testing build; I guess you are using that ?

gldni:
Here is the declaration of g_Ledger_Tree_DS. I used the treeview sample to model my treeview, so whatever type was in the sample is what I used.

/**
  • @properties={typeid:35,uuid:“A06B6158-0A4C-42D2-829F-BDAE76615DCD”,variableType:-4}
    */
    var g_Ledger_Tree_DS;

so add there @type {JSDataSet} to the doc, type the global what it really is.

gldni:

forms["Detail_Body"].batchAmount = check_amount; //Warning: The property batchAmount is undefined for the type Form

If you do it like this then it maps to the default RuntimeForm type
Why aren’t you doing:

forms.Detail_Body.batchAmount = check_amount

Form Detail_Body is created using the solutionModel:

//clone form Ledger_Payment_Detail_test_Head_Foot

newForm1 = solutionModel.getForm(“Ledger_Payments_Detail_Head_Foot”);
body = solutionModel.cloneForm(“Detail_Body”,newForm1);



Is there another way for me to pass values to the variables on Detail_Body? Since the form is created using the solutionModel, forms.Detail_Body.batchAmount = check_amount give me these warnings -
Multiple markers:
-The property Detail_Body is undefined for the type Forms<eClinic>
-The property Detail_Body is undefined for the type Forms<eClinic>

ahh ok they are completely dynamic then do it the other way around

forms[“Detail_Body”][‘batchAmount’] = check_amount;

gldni:

I don’t know why you get warnigns for these:

elements.treeview.xxxx

that is our DbTreeView bean right?
What happens if you type this: elements.treeview.
and then press cltr-space so code complete this?

I use the Servoy TreeView Bean from ServoyForge. When I type elements.treeview. and press cltr-space it tells me there are no completions available. I don’t think I’ve changed anything with the treeview since I installed it using Servoy 5.2. Pretty sure the code completion was working then.

Will also see if i can test this.

tested it and it works fine for me also.
only 1 method call that has a warning:

elements.treeview.setDataSet(globals.createDataSet());

will see if i can fix that in our code or that the bean should do something different.

Gabi Boros:
when using servoy-treeview.jar, that is the stable version, I do not
see any warnings, but I do see them when using servoy-treeview-test.jar,
that is a testing build; I guess you are using that ?

In the application_server\plugins folder i have servoy-treeview.jar. Is there anyplace else I need to look/put the .jar file?

those should be in the beans dir, not in the plugins dir.

That could be the problem… :oops:

OK. I moved servoy-treeview.jar file to the beans dir and still have warnings.

selectedNodes = forms.Ledger_List.elements.treeview.getSeletedNodes();  //Warning: The function getSeletedNodes() is undefined in this script
parentNodeID = forms.Ledger_List.elements.treeview.getParentNode(selectedNodes[0]);  //Warning:  The function getSeletedNodes() is undefined in this script

What else do I need to check?

Did you restart Servoy after you moved the jar ?

Hi Robert. I restarted Servoy just to make sure it had been done and I still have the warnings. I’m also still getting warnings with my global dataset:

rowCount = globals.g_Ledger_Tree_DS.getMaxRowIndex();  //Warning: The function getMaxRowIndex() is undefined in this script

Here is my global declaration:

/**
 * @type {JSDataSet}
 * 
 * @properties={typeid:35,uuid:"A06B6158-0A4C-42D2-829F-BDAE76615DCD",variableType:-4}
 */
var g_Ledger_Tree_DS;

I added @type {JSDataSet}. Do I need to change the variableType?

Hi Nicholas,

You don’t need to use the curly brackets when you use the @type. You can just use the following syntax:

@type JSDataSet

You don’t need to use the curly brackets when you use the @type

You should always use the curly braces around the types! See the docs: http://wiki.servoy.com/display/public/D … sing+JSDoc

Hmm…I stand corrected.

franticly fixing my own code :oops:

are these errors sticking when you just touch the file onces?

If you change something in a completely other file (like adding a type on the global)
the warnings somewhere else that touches the globals are not automatically gone (the js build system is not that smart yet)
you have to touch the file or do a project->clean so that a full build is triggered

also with the treeview bean, if you just create a new form, place the bean on it, go to the js editor of that form and do elements.name. do you get code completion??