How to Remove zero amount line fom axapta form by code - forms

When we are processing EOS(end of service) of an employee then system automatically generate the zero line 0.00 as Encashment quantity for rendom employee somehow.My client don't want this zero line in this form becuase when they are trying to post EOS to general ledger its showing the error as amount can't be post without value.So how to code in x++ to remove the zero amount line from my EOS form if there is any 0.00 encashment amount.
enter image description here
In Above screenshot system has calculated the encashment quantity as zero so when we processed EOS. Kindly requesting give some suggestions to handle this scenario by X++ code.

If you are using a datasource to get the value then there is a property called "Insert if empty" on the datasource (In this case the datasource with the EncashmentQuantity field) which is automatically set as "yes" but you can change it to "no" and the value should not be shown if it is 0. I am not sure this is what you are talking about but it might be.

I hope to understood the question.
"My client don't want this zero line in this form becuase...."
I think you have this way, If you want to filter the record without 0 Value by code, you can use filter in DataSource rightClick override executequery method and insert code looklike follow:
public void executeQuery()
{
this.query().dataSourceTable(tableNum(**YourTablename**)).addRange(fieldNum(**YourTableName**,**YoutFilterField**)).value(strFmt("%1", '>0'));
super();
}
ForExample :
this.query().dataSourceTable(tableNum(LedgerJournalTrans)).addRange(fieldNum(LedgerJournalTrans,AmountCurCredit)).value(strFmt("%1", '>0')); // DISCARD all record lower than 0
or
this.query().dataSourceTable(tableNum(LedgerJournalTrans)).addRange(fieldNum(LedgerJournalTrans,AmountCurCredit)).value(SysQuery::valueNot(0));
I share this useful links :
Expressions in query ranges
SimilarQuestion
StandardGuide
Good work!

Related

In flutter TextFormField I can't clear the value when using double.parse

I am creating a dialog that allows a user to make a payment and it subtracts it from their current balance.
So if their balance is $100 and they type $25 into the form field and hit submit the balance is now $75.
That all works. My problem is if I erase everything in the TextFormField and hit submit the $100 balance is now $98.
That's because when I erase the value the first character sticks in the value and I can't delete it by hitting the delete key.
When I print the value, hit the delete key, and look at the console it looks like this...
25.00
25.0
25.
25
2
No matter how many times I hit delete, the 2 won't erase.
I narrowed it down to double.parse being my problem. Here is the code:
onChanged: (val){balance = debtBalance-double.parse(val);
print(val);},```
I think this is because parse method fails when provided with empty or null value. It doesn't really make sense to parse an empty string anyways, so just use default value 0 in those cases.
balance = debtBalance - ((val ?? '').isEmpty ? 0 : double.parse(val));
This code snippet checks if new text value is empty, and if so it substracts 0 instead of parsing.

How do I prevent users to use thousands separator in FileMaker Pro?

In FileMaker Pro, when using number field, the user can choose to use a thousand separator or not. For example, if I have a database with a field for the price of an item, the user can either enter 1,000 or 1000.
I am using my database to generate an XML file that needs to be uploaded. The thing is, that my XML scheme dictates that only a value of 1000 is allowed and not 1,000. Therefore, I want to either automatically remove the comma, or (my preference in this case) alert the user when trying to enter a value with a thousand separator.
What I tried is the following.
For the field, I am setting Validation options. For example:
Require Strict data type: Numeric Only
Validated by calculation: Position ( Self ; ","; 1 ; 1 ) = 0
Validated by calculation: Self = Substitue ( Self, ",", "")
Auto-enter calculation: Filter( Self ; "0123456789." )
Unfortunately, none of these work. As the field is defined as a number (and I want to keep it like this, as I am also performing calculations based on this number), the Position function and the Substitute function apparently ignore the thousand separator!
EDIT:
Note that I am generating my XML by concatenating a string, for example:
"<Products><Product><Name>" & Name & "</Name><Price>" & Price & "</Price></Product></Product>"
The reason is that what I am exporting is dependent on the values in my database. Therefore, I am not using the [File][Export records...] function.
Auto-enter calculation will work, but you need to uncheck the box "Do not replace existing value of field" (which is checked by default).
I'd suggest using the calculation GetAsNumber(self) as the auto-enter calc. If it should only contain integers, wrap that in a call to Int()
I am using my database to generate an XML file that needs to be uploaded. The thing is, that my XML scheme dictates that only a value of 1000 is allowed and not 1,000.
If this is only a problem when you export, why not handle it when exporting?
If you are exporting as XML using XSLT, you can add an instruction to
your stylesheet to remove the comma from all number fields;
Alternatively, you can export from a layout where the field is
formatted to display without the comma and select the Apply current's layout data formatting to exported data option when
exporting.
Added:
Perhaps I should have clarified. I am not using the export function to generate the XML as there is some logic involved in how the XML should be formatted (dependent on the data that I want to export). What I do instead is that I make a string where I combine XML-tags and actual values from the database.
IMHO, you're making a mistake by not taking advantage of the built-in XML/XSLT export option. Any imaginable logic can be implemented this way, without burdening your solution with the fragile task of creating a valid XML.
In any case, if you're using the field in a calculation, you can replace all references to it with:
GetAsNumber (YourField )
to get an unformatted, numeric-only, value.
Your question puzzles me. As far as I know, FileMaker does not store the thousands separator, but rather offers it only as a display option.
That's also why those functions can't find it.
Are you sure you are exporting the raw data and not a "formatted as layout" variant?

Empty rows in report when using count function

I am using BIRT reporting with my mongodb datasource. I am trying to COUNT some events. COUNT function gives the correct value but there is big empty space at the end of the page depending upon the count value. If the count value is big then the rest of the page is empty and on the next page same record is coming e.g. :
In this Image the rest of the page is empty and same record is coming on the next pages also. It looks like empty spaces are being printed.
This is how my report looks like :
The COUNT function:
I have tried using SUM also but I get this error when I use SUM function instead of COUNT :
org.eclipse.birt.report.engine.api.EngineException: A BIRT exception occurred. See next exception for more information.
Can not convert the value of True to Double type.
at org.eclipse.birt.report.engine.executor.ExecutionContext.addException(ExecutionContext.java:1245)
at org.eclipse.birt.report.engine.executor.ExecutionContext.addException(ExecutionContext.java:1224)
at org.eclipse.birt.report.engine.executor.DataItemExecutor.execute(DataItemExecutor.java:101)
at org.eclipse.birt.report.engine.internal.executor.wrap.WrappedReportItemExecutor.execute(WrappedReportItemExecutor.java:46)
at org.eclipse.birt.report.engine.internal.executor.emitter.ReportItemEmitterExecutor.execute(ReportItemEmitterExecutor.java:46)
at org.eclipse.birt.report.engine.internal.executor.dup.SuppressDuplicateItemExecutor.execute(SuppressDuplicateItemExecutor.java:43)
at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.execute(HTMLAbstractLM.java:468)
Please help, thanks in Advance.
I got the issue to this problem. If we select "Hide Detail" Option from the group then this problem go away.

updating existing data on google spreadsheet using a form?

I want to build kind of an automatic system to update some race results for a championship. I have an automated spreadsheet were all the results are shown but it takes me a lot to update all of them so I was wondering if it would be possible to make a form in order to update them more easily.
In the form I will enter the driver name and the number o points he won on a race. The championship has 4 races each month so yea, my question is if you guys know a way to update an existing data (stored in a spreadsheet) using a form. Lets say that in the first race, the driver 'X' won 10 points. I will insert this data in a form and then call it from the spreadsheet to show it up, that's right. The problem comes when I want to update the second race results and so on. If the driver 'X' gets on the second race 12 points, is there a way to update the previous 10 points of that driver and put 22 points instead? Or can I add the second race result to the first one automatically? I mean, if I insert on the form the second race results can it look for the driver 'X' entry and add this points to the ones that it previously had. Dunno if it's possible or not.
Maybe I can do it in another way. Any help will be much appreciated!
Thanks.
Maybe I missed something in your question but I don't really understand Harold's answer...
Here is a code that does strictly what you asked for, it counts the total cumulative value of 4 numbers entered in a form and shows it on a Spreadsheet.
I called the 4 questions "race number 1", "race number 2" ... and the result comes on row 2 so you can setup headers.
I striped out any non numeric character so you can type responses more freely, only numbers will be retained.
form here and SS here (raw results in sheet1 and count in Sheet2)
script goes in spreadsheet and is triggered by an onFormSubmit trigger.
function onFormSubmit(e) {
var sh = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet2');
var responses = []
responses[0] = Number(e.namedValues['race number 1'].toString().replace(/\D/g,''));
responses[1] = Number(e.namedValues['race number 2'].toString().replace(/\D/g,''));
responses[2] = Number(e.namedValues['race number 3'].toString().replace(/\D/g,''));
responses[3] = Number(e.namedValues['race number 4'].toString().replace(/\D/g,''));
var totals = sh.getRange(2,1,1,responses.length).getValues();
for(var n in responses){
totals[0][n]+=responses[n];
}
sh.getRange(2,1,1,responses.length).setValues(totals);
}
edit : I changed the code to allow you to change easily the number of responses... range will update automatically.
EDIT 2 : a version that accepts empty responses using an "if" condition on result:
function onFormSubmit(e) {
var sh = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet2');
var responses = []
responses[0] = Number((e.namedValues['race number 1']==null ? 0 :e.namedValues['race number 1']).toString().replace(/\D/g,''));
responses[1] = Number((e.namedValues['race number 2']==null ? 0 :e.namedValues['race number 2']).toString().replace(/\D/g,''));
responses[2] = Number((e.namedValues['race number 3']==null ? 0 :e.namedValues['race number 3']).toString().replace(/\D/g,''));
responses[3] = Number((e.namedValues['race number 4']==null ? 0 :e.namedValues['race number 4']).toString().replace(/\D/g,''));
var totals = sh.getRange(2,1,1,responses.length).getValues();
for(var n in responses){
totals[0][n]+=responses[n];
}
sh.getRange(2,1,1,responses.length).setValues(totals);
}
I believe you can found everything you want here.
It's a form url, when you answer this form you'll have the url of the spreadsheet where the data are stored. One of the information stored is the url to modify your response, if you follow the link it will open the form again and update the spreadsheet in consequence. the code to do this trick is in the second sheet of the spreadsheet.
It's a google apps script code that need to be associated within the form and triggered with an onFormSubmit trigger.
It may be too late now. I believe we need a few things (I have not tried it)
A unique key to map each submitted response, such as User's ID or email.
Two Google Forms:
a. To request the unique key
b. To retrieve relevant data with that unique key
Create a pre-filled URL (See http://www.cagrimmett.com/til/2016/07/07/autofill-google-forms.html)
Open the URL from your form (See Google Apps Script to open a URL)

What is the meaning of the following line of code?

I am learning ADO.NET and now I am trying to understand the SqlDataReader. I am trying to learning by using this tutorial and I am facing some difficulties now in understanding the following part of the code mentioned HERE:
while (rdr.Read())
{
// get the results of each column
string contact = (string)rdr["ContactName"];
string company = (string)rdr["CompanyName"];
string city = (string)rdr["City"];
// print out the results
Console.Write("{0,-25}", contact);
Console.Write("{0,-20}", city);
Console.Write("{0,-25}", company);
Console.WriteLine();
}
I want to understand the meaning of "{0, -25}"
This means that the WriteLine method schould print the value of the first parameter, in your case contact, to a width of 25 characters. The minus in front of the 25 indicates a left justified output.
That is a format specifier for .NET Console.Write().
See documentation explaining here:
http://msdn.microsoft.com/en-us/library/9xdyw6yk.aspx
IN SqlDataReader, it reads record from database based on query.
sqlDataReader read record at a time single row. it means rdr["ContactName"] is one value and it read and move to string contact and so on every fields.
It fetch all record in while loop.
And Console.Write("{0,-25}", contact) is used to format output.