I have a Xpage with three fields, all Number declared; Nominal, Price and PaymentAmount.
I want to calculate the PaymentAmount using Nominal * Price.
In SSJS onChange I use the following code:
var price = getComponent("Price").getValue();
to get the value from the field "Price".
In Sweden we enter our numeric values as this #.###,## 1.234,56
If I enter the values Nominal=10 and Price=2,5 in my Xpage and try to calculate using the above mentioned formula the value stored in var "price" is converted to 25 and of type long.
Please advice
/M
I'm an idiot, unfortunatly.
Did this:
<inputText value="#{document1.Price}" id="Price" required="true" size="10">
<this.validators>
<validateRequired message="Price is required">
</validateRequired>
</this.validators>
<this.converter>
<convertNumber type="number" locale="sv">
</convertNumber>**
</this.converter>
</inputText>
and it works!
Thanks you ALL for input
I take it "Price" is an edit box? If so you can set it to Number field, then Display format to currency. The currency code will define how that number is displayed.
When you get the components value it should come back as a normal number you can work with.
getComponent gets the UI component value and that's why it does not necessarily reflect the data type that will be saved (in UI everything is string). It's also a slow way to get the value.
Try datasourcename.getItemValueDouble("itemname") instead. Note that you need to use the field name on Form, not the component name.
Regarding number format make sure your djConfig locale is Sweden, probably se-se. For me in Finland it looks like this:
<script type="text/javascript" src="/xsp/.ibmxspres/dojoroot-1.6.1/dojo/dojo.js" djConfig="locale: 'fi-fi', parseOnLoad: true"></script>
It should use the browser locale. To force this in SSJS you can do:
context.setLocaleString("se-SE");
in beforePageLoad event.
Related
I have an array of objects which i am displaying as a line graph in kendo.
The category axis is a date and is data between a large period of time. I want to display this date neatly (In the UK/ Rest of world date format). However i cannot seem to get this to work. Here is my HTML code below
<kendo-chart [transitions]="true">
<kendo-chart-axis-defaults [majorGridLines]="{ visible : false}">
</kendo-chart-axis-defaults>
<kendo-chart-category-axis>
<kendo-chart-category-axis-item>
<kendo-chart-category-axis-item-labels culture="en-GB"
format="d"
step="50">
</kendo-chart-category-axis-item-labels>
</kendo-chart-category-axis-item>
</kendo-chart-category-axis>
<kendo-chart-value-axis>
<kendo-chart-value-axis-item>
<kendo-chart-value-axis-item-labels culture="en-GB"
format="c">
</kendo-chart-value-axis-item-labels>
</kendo-chart-value-axis-item>
</kendo-chart-value-axis>
<kendo-chart-series>
<kendo-chart-series-item type="line" [data]="items | async"
field="cumulativePercentReturn"
markers="markers"
dashType="solid"
categoryField="startDate">
</kendo-chart-series-item>
</kendo-chart-series>
</kendo-chart>
The dates, however, are still rendered as yyyy-mm-dd etc.
The kendo for angular 2 guide is not very specific here, asking me to refer to a globalisation article which does not exist on the site.
If anyone could aid me in getting this working. I have tried editing that format string in every way i can sensibly think of.
So i solved this!
It turned out the JSON data returned was showing the date formatted as a string. The date formatting worked when i cast this string back to a date.
I'm working on a small Project using Primefaces.
I'm trying to display value from my database with special formation
I store a String in my database which Looks like this 40;99;1;0;0;12
These are six different numbers seperated with a ;and they have a range between 0-99.
I want to display this value in an InputMask to make sure that the user doesn't forget the ;.
Now I have a problem with the format.
I'm using this
<p:inputMask id="myID" placeholder="Value" value="#{myClass.value}" mask="9?9;99;99;99;99;99"/>
I'm trying to say that the mask contains six "fields" for a number input and each field can contain a number between 1-99.
The problem is if the user writes the input as this 30;10;0_;0_;0_;4_Primefaces converts it to 30;10;00;04;__;_
Is there a good way to let the mask know that it can be a number with one or two digits?
Or is there a way to say, if input has just one digit put a 0 first
I dont know if this solution fits your needs, but you can define a custom mask
$.mask.definitions['h'] = "[0-9]{0,1}";
$("#form\\:your_input_mask_id").mask("hh;hh;hh;hh;hh;hh");
in your document.ready function. This will leave the _ character as is, but I guess you can handle it in your code when splitting the string and handling each part. I've put form\: because you generally put these inputs inside a form with id form. Change accordingly!
This has the downside though, that if you dont enter something, it will also validate, regardless of not being between 1 and 99.
I have : <xp:repeat id="repeatColor" value="#{productcolors}"
var="rowData" indexVar="rownum" >
PROBLEM : rownum goes from 0 to the last correct value, but rowData is always the same
This repeat control is bound to a view "productcolors" , a view with a key on product code.
This view has a first column with the product code , ascending (for the key).
It also has a second and a third column with ascending multiple value fields.(second is framecolor, third is upholstery color)
The idea is that the repeat control goes through the different colors for the selected product, but it only shows the first one and does that the number of times (rownum increases correctly)that there are colors for the selected product.
EDIT :
So I have for example a product called "A" available in framecolors "1" "2" and "3"
When I am using the repeat control rownum changes from 0 to 2 but rowData is always the reference of framecolor "1". I don't know why rowData isn't changing.
When I use rowData.getUniversalID() I am getting 3 times the ID of the document containing the multiple value field with the 1 , 2 and 3 in it, which is I guess normal ? But how can I get a handle to those different values inside it ?
SECOND EDIT
I tried :
var testje:string = rowData.getUniversalID();
var db:NotesDatabase = session.getDatabase(database.getServer(),"product/colors.nsf");
var doc:NotesDocument = db.getDocumentByUNID(testje);
test = doc.getItemValueString("colorUpholstery");
The result is that "test" only holds the first item of the multiple value field "colorUpholstery" .
How is that possible ? I thought I would get the complete value of the "colorUpholstery" field ?
Maybe because I only have reader access(Publicaccess) to the colors.nsf database ?
It would be nice to see a little more code... like what's inside the repeat.. just to get a better feel for it to go along with your description of the Notes View.
rowData should be an XSPViewEntry... basically a NotesViewEntry... I suggest you first do something like rowData.getDocument().getUniversalId() to make sure it is iterating the documents correctly. I'm sure it is.
It sounds like you're trying to do something with a multi-value field.. are you also setting the view to use display multiple values as row entries? or whatever that setting is? That might get dicey if that's turned on. Not sure.
Again I'm not totally following what what the goal is but I would first test to make sure it is actually repeating the expected documents. then it's all about fine tuning.
EDIT: Ok... some thoughts based on your additional info:
I suspect that your problem is the use of the view setting "show multiple values as separate entries". Each is the same document really. So that's likely not helping you here. I'm still a little fuzzy on exactly what you want for the output. Is this from a "view page" of maybe products? a "form page" of a single product?
I ASSUME you want all the colors for a single product? And this is a lookup view right? so you're on your product "document" and now you want to list all the colors?
Assuming so...
Use SSJS and the object model. Do a lookup to find the SINGLE document that has the multi-value color field for your current product. then return to a repeat control something like:
lookupDoc.getItemValue("colorField")
I'm not 100% sure that's the correct syntax. The point is you can send a multi-value field to a repeat control and it will repeat it. Much easier then trying to use view tricks.
If your goal is to have a Repeat of multiple products.. and in side each "row" to show all the available colors then you're looking to have a nested repeat really... The outer repeat (outerData) to iterate over all the main products and inside that another repeat (innerData) for the colors. Inside that repeat code you use the "outerData" to get the multi-value field. Something like:
outerData.getDocument().getItemValue("colorField")
Assuming I'm understanding you correctly these are my suggestions.
I did do an example of nested repeats like this on an early NotesIn9. I believe it was this one: http://notesin9.com/index.php/2010/03/30/notes-in-9-show-14-repeats-repeated/
Maybe that will help.
Second Edit Response:
Based on the code you added you're using "doc.getItemValueString()" By design that will only get you the first value of a multi-value field. This is the same as saying in LotusScript:
doc.colorUpholstery(0)
or the less commonly used
doc.getItemValue("colorUpholstery")(0) ' I might have that wrong. I never really used it
Again if you want to make a list of all the colors I'd use a repeatControl and pass in:
doc.getItemValue("colorUpholstery") then your "rowData" for that repeat will be each value. I've seen others avoid the repeat and doing some javascript explode or implode type thing I believe. using "\N" or something as a separator for a new line. I just use a repeat. Easer for me to understand.
Again I THINK everything you need really is in NotesIn9 episode 14.
In my Lotus Notes Database, I want to fill the choices available in a dialog list based on the previously entered values for this field.
I set type of the field to "Dialog list", chose "Use formula for choices" and selected "Allow values not in list".
However, I don't know what to enter as a formula:
The formula's result should be all values for the field Foo specified in the database.
I tried the following formula which results in an empty list, however:
#Unique(SELECT Foo)
There are definitely documents with values for Foo in the database.
Which formula can I use?
Or do you know better solutions to my problem than using a formula?
Many thanks in advance for your responses!
You need to create a view with at least a column that displays the Foo field. You can then use #DbColumn in your formula to retrieve all values from e.g. column 1 containing the Foo field:
#Unique(#DbColumn("";"":"database.nsf";"Your new view";1))
Here is more informatiom about #DbColumn: http://publib.boulder.ibm.com/infocenter/domhelp/v8r0/index.jsp?topic=%2Fcom.ibm.designer.domino.main.doc%2FH_GENERATING_CHOICES_FOR_LISTS_STEPS.html
Similar way, but error handling included.
Look := #DbColumn("":""; ""; "$LookFoo"; 1);
#If(#IsError(Look); ""; #Unique(Look))
Database parameter can be empty, if you are reading from the current. If there is a problem with cache, you can make first parameter like - #DbColumn("":"NoCache";...
Hope it helps.
I am trying to create a custom view for a sharepoint list, similar to the one explained here:
http://msdn.microsoft.com/en-us/library/ms916812.aspx
I have a column which is a number field with values ranging from 0 to 100.
I need to create a view style which will display an image in the column based on the column value, instead of displaying the value.
If the value is in between 0 to 25, i need to display an image 25.gif
If the value is in between 25 to 50, i need to display an image 50.gif
.....
and so on.
The calculation involved here is the CEILING function, CEILNG(NumberColumn,25)
The problem is, I need to specify this in CAML, in the VWSTYLES.XML
How can I specify the Ceilnig function in CAML?
Some other options could be:
As the VWSTYLES.XML is just a really awkward way of rendering html, you could code some javascript into your VWSTYLES.XML to render the image tag with the correct source.
Alternately, develop an ascx control and get the VWSTYLES.XML to render a control instead of HTML. So long as you can register the control on the page correctly.
CEILING is used for rounding decimal values. Since you only have a few images, I would just use nested IF functions:
=IF([NumberColumn]>76, "100.gif", IF([NumberColumn]>51, "75.gif",
IF([NumberColumn]>26, "50.gif", "25.gif")))
You could also use the MOD function to convert 0-24 to 0, 25-49 to 1, etc. and calculate your image from there.