I have a Birt Report which read some stuff from a database.
After that i want to increment a global Integer for every Detailrow that is loaded.
So far i have initialized a global Integer with the following lines:
importPackage(Packages.java.lang);
reportContext.setPersistentGlobalVariable("minTotalPlus", new Integer(0));
After that i added the following line into a field in my detail row:
reportContext.setGlobalVariable("minTotalPlus", new Integer reportContext.getGlobalVariable("minTotalPlus")) + 1);
When i preview the report i get an "java.lang.NumberFormatException: null" which means that the global variable is null. Why is that so? How could I fix that?
Dont' declare variables like that in the initialize method
declare the like the following
materiales=0;
tools=0;
then in the fetch method
use the following
tools++;
...etc.
Related
I'm new with X++ and I'm trying to modify the INIT method of a form in order to greet the user wit a message on top of the form.
The greeting message should look like "Happy Birthday EmplTable.name!".
The code from the INIT METHOD looks like this till now:
public void init()
{
CustName custName = SELECT EmplTable.name FROM Empltabe JOIN UserLogInfo WHERE EmplTable.EmplId == UserInfo.UserId;
;
//"#NET4183"
super();
GreetingMessage.text(strfmt("#NET4183", custName));
}
I have a hard time understanding what is wrong here and why I can't initialize the custName variable.
Thank for the help!
Have a great day!
All variables must be declared before they can be used. X++ does not allow variable declarations to be mixed with other X++ statements; variables must be declared before X++ statements.
Declaration of Variables
You should declare variables EmplTable, UserInfo before you can use them in select statement.
Results of a select statement are returned in a table buffer variable. If you use a field list in the select statement, only those fields are available in the table variable.
You can assign value to your custName variable using this peace of code
custName = emplTable.name;
This link will give you a hint how to find the current user
curUserId Function
In the ReqTransPO form I want to use the tmpAccountSum table to store some values in which I later need to filter my grid.
In the classdeclaration I declared:
tmpAccountSum mytable;
In a helper method I have:
//Store data in tmptable
ttsbegin;
mytable.AccountNum = _reqTrans.RefId;
mytable.Txt = _reqPo.RefId;
mytable.Voucher = enum2str(_prodstatus);
mytable.insert();
ttscommit;
I don't get an error on 'mytable' but can't really use it / it's not initialized. If I add a watch in debug I see:
Error: Symbol "mytable" was not found
If I declare mytable locally it works ok.
Guess I'm doing something wrong?
Thanks in advance,
Mike
My extrasensory perception tells me, that your helper method is static.
Static methods do not have access to instance variables declared in classDeclaration.
THIS QUESTION IS NOT ABOUT HOW TO SET DEFAULT VALUE OF A WIDGET
Hello Symfonians!
I had a fundamental doubt about forms, Im putting 2 scenarios below.
I have a customModelForm that extends a modelForm.
1> If I do not specify a default value for a form field
new: field is empty
edit: field shows the value in the object
2> If I specify a default value for a field,
new: field shows default value
edit: field shows default value
I am trying to avoid the EDIT mode behaviour in scenario 2.
The default value should only be displayed when the value in the object is not set.
I am calling parent::configure after setting the default value. Do we have any control on the 'bind' event?
Thanks
This shouldn't be happening, at least in Doctrine. The part of the code where this is happening is in updateDefaultsFromObject in sfFormDoctrine. The relevant lines are:
if ($this->isNew())
{
$defaults = $defaults + $this->getObject()->toArray(false);
}
else
{
$defaults = $this->getObject()->toArray(false) + $defaults;
}
updateDefaultsFromObject does net get called until the entire configure chain is done, so something else must be going on here.
Are you using Doctrine? Are you using the most current version of Symfony (there was a bug here a while ago)? Are you sure the default is getting set in the configure method of your form?
The isNew check richsage is recommending should be avoided. There is a larger issue here as the proper behavior is for default value to get overwritten by an existing object's values.
First of all, call parent::configure() first in your configure() method. That way you don't run the risk of your configuration being overwritten by the parent configuration.
You can set defaults based on the model's status by doing something like the following in your configure() method:
if ($this->getObject()->isNew())
{
// do something here but only if the object is new
}
else
{
// the object is being edited
}
i get this error when i retrieve an XML that only has 1 node (no repeating nodes) and i try to store in an ArrayCollection. -When I have MORE than 1 "name" nodes...i do NOT get an error. My test show that XMLListCollection does NOT work either.
TypeError: Error #1034: Type Coercion failed: cannot convert "XXXXXX" to mx.collections.ArrayCollection.
this error occurs as the line of code:
myList= e.result.list.name;
Why can't ArrayCollection work with a single node? I'm using this ArrayCollection as a dataprovider for a Component -is there an alternative I can use that will take BOTH single and repeating nodes as well as work as a dataprovider? Thanks in advance!
code:
[Bindable]
private var myList:ArrayCollection= new ArrayCollection();
private function getList(e:Event):void{
var getStudyLoungesService:HTTPService = new HTTPService();
getStuffService.url = "website.com/asdf.php";
getStuffService.addEventListener(ResultEvent.RESULT, onGetList);
getStuffService.send();
}
private function onGetList(e:ResultEvent):void{
myList= e.result.list.name;
}
the problem here is, that if you only have one row Flex will complain since it cannot use the result as arrayCollection.
My work around was, that you put number of rows into your XML with the data you want to return:
for example I did:
<list><nr_rows>3</nr_rows><name>...</name><name>...</name><name>...</name></list>
So when I get the result back I do a check of how many rows I am getting with (You can get the number of rows returned from MySQL query with mysql_num_rows)
e.result.list.nr_rows
So if this is one, you add Object to the arrayCollection, if there are more than one you can just use result and equal it to AC (in this case projects is AC):
if (event.result.list.nr_rows == '1'){
myList.addItem(event.result.list.name);
} else {
myList = event.result.list.name;
}
If you are not particular about getting the final result onto a ArrayCollection, you can do the following to get the final result onto an XMLList or XMLListCollection.
1) set the resultFormat property of HTTPService to e4x.
2) Do not mention the root xml tag name while referencing it. Reference the output as: myList:XMLList = e.result.name.
This works whether the retrieved XML has one or more than one elements.
I just had this problem today and it led me to this question. I'm not sure if your use-case is exactly the same as mine, but you might want to try showRoot="true" on the mx:Tree. It seems to force the root node to be shown when there is only one item, and gets ignored with multiple items.
add a row object to get the row of the XML node can work, but I think some better method have be, is ActionScript is as powerful as Java?
I'm calling a stored procedure from C# .net and one of the string parameters is null. When that is the case, I pass DBNull.Value. However, I get the above error. Any ideas?
If the string is null, you will see this error. To avoid it, you can set a default parameter value in your stored proc, or you can pass DBNull.Value if your string is null.
You get this if the value of a parameter is "null" (as opposed to DBNull.Value).
Are you sure the parameter value is DBNull.Value?
Do you have access to the Stored Procedure? If so, (And if the Stored procedure logic will allow it), modify the declaration of the input parameter to add " = Null" at the end, as in
Create procedure ProcName
#MyParameterName Integer = Null,
-- con't
As...
Can you give more details like how you are calling the sproc, the parameter itself and the value. You know in your sproc you can set default values for variables.
Something to the effect of:
ALTER SprocMySproc
#myvar varchar(50)=NULL
SELECT blah FROM MyTable WHERE MyField=#myvar OR #myvar IS NULL
Your actual C# or vb.net code can then ignore sending the parameter if it is null or empty
if(!(String.IsNullOrEmpty(myVar)))
{
//pass the parameter
mySQLCommandObject.Parameters.Add("#myvar", sqldbtype.varchar).Value = myVar;
//other code...
}