There is floating point number field whose name is "new_poscost". The existing value of the field is 0,00 or it can be any decimal value. I want to sum a value with it. But I'm getting a cast error.
In first line of code poscost variable is getting the value of attribute. When it comes to assign sum of values to another entity's attribute, I'm getting "cast is not valid" error.
decimal poscost = postEntity.Attributes.Contains("new_poscost") ?
(decimal)postEntity["new_poscost"] : 0m; // value is assigning to poscost properly.
FlightHotel.Entities[0].Attributes["new_poscost"] = poscost+
(decimal)FlightHotel.Entities[0]["new_poscost"];
Try to use following approach:
double podnost = postEntity.Contains("new_poscost") ? new_poscost.GetAttributeValue<double>("new_poscost") : 0;
Related
I want to set a specific value in a table to default format "General".
To implement this I follow the spec:
Blank and null values in Excel add-ins
When you specify a blank value for a property (i.e., two quotation
marks with no space in-between ''), it will be interpreted as an
instruction to clear or reset the property. For example:
...
If you specify a blank value for the
numberFormat property, the number format is reset to General.
...
My code is:
const formats = [["0", "0"], ["", "0.00"], ["0.00", "0.00"]];
const range = sheet.getRange("D3:E5");
range.numberFormat = formats;
The usage of empty quote lead to an error message from the excel.js API :
message: "The argument is invalid or missing or has an incorrect format."
when I try to download a table with grouping by fields, it does not appear correctly in the pdf, can anyone help me?
รง
Are you referring to the null values appearing in the output. If so then you can use an accessor on the column definitions to convert the null value into an empty string so it renders correctly.
To start with we define an accessor function outside of Tabulator:
var nullFixingAccessor = function(value){
return value === null ? "" : value; //return value or empty string if it is null
}
Then in each column definition for a column that might contain a null we set it on the accessorDownload property:
{title:"Act", field:"act", accessorDownload:nullFixingAccessor},
This will then convert the null values to an empty string when the pdf is downloaded
I am trying to validate number value which will include integer as well as float values. Following is my implementation for the same.
Joi Schema.
const numcheckschema = Joi.object().keys({
v1:Joi.number().empty("").allow(null).default(99999),
v2:Joi.number().empty("").allow(null).default(99999),
v3:Joi.number().empty("").allow(null).default(99999)
})
Object
objnum={
v1:"15",
v2:"13.",
v3:"15"
}
objValidated = Joi.validate(objnum, numcheckschema);
console.log(objValidated);
When i execute the above mentioned code I get an error
ValidationError: child "v2" fails because ["v2" must be a number]
as per the documentation when we tries to pass any numeric value as a string it converts the values to number but here in this case my value is 13. which is not able to convert into number and throwing an error.
Is there any way by which we can convert this value to 13.0
You can use a regex in order to match numbers with a dot, for instance:
Joi.string().regex(/\d{1,2}[\,\.]{1}/)
And then combine both validations using Joi.alternatives:
Joi.alternatives().try([
Joi.number().empty("").allow(null),
Joi.string().regex(/\d{1,2}[\,\.]{1}/)
])
However, I think you may need to convert the payload to number using Number(string value). You need to check the payload type, if it isn't a Number, you need to convert it.
If you want to know more about the regex used in the example, you can test it in here: https://regexr.com/
In lotusScript: I've used:
doc.DocDate = Format(document.get("DatePublished"),"mm/dd/yyyy") 'Rem return 08/22/2017
In formula: I've used for to get year:
#Year(DocDate)
But when i run the program i get the error : "incorrect data type for operator or #function time/date expected". How to fix it?
Get date value with
document.DatePublished(0)
or
document.GetItemValue("DatePublished")(0)
Then your field DocDate should be calculated properly.
#Year() expects a NotesDateTime value. DocDate is a String value though. You can change your formula to
#Year(#ToTime(DocDate))
and it will work if your language settings are set to US date format.
I am trying to update a computed fields value on click of a button with a value of a edit box + its own value.
Code written on button: here i put value of edit box in scope variable and make edit box blank. comment_te is the name of edit box
requestScope.put("commentValue", getComponent("comments_te").getValue);
getComponent("comments_te").setValue("");
Code written for value of computed field: comments is the name of computed field
getComponent("comments").getValue + "\n" + requestScope.get("commentValue")
But I get the output is:
0 com.ibm.xsp.component.xp.XspInputText#65426542
Please help me with this.
You're missing the parentheses in your calls to getValue(). By omitting these, you're returning a pointer to the getValue method of the component, not the result of invoking that method. Change each reference to getValue to getValue(), and you'll get a different result.
Your code returning the Object.
Try the following.
This following code get the the editbox value and set to a scope variable.
requestScope.commentValue = getComponent("comments_te").value;
getComponent("comments_te").value = "";
This following code sets the value to the computed field.
getComponent("comments").value = getComponent("comments").value + "\n" + requestScope.commentValue;
When you are appending the value to the computed field, as default it will add 0 to its value. Do the validation if you want.
I hope this helps you...!!!