Exception occured with replaceItem and date value - xpages

I am getting the following error when trying to set a date value using #Date value with replaceItemValue.
The error I am getting occurs on the last line of code here:
var dt = #Date(2012,1,1);
docContractor.replaceItemValue("NewField","Hello World");
docContractor.replaceItemValue("ContractorStartDateTime",dt);
The error is:
Error while executing JavaScript action expression
Script interpreter error, line=21, col=31: [TypeError] Exception occurred calling method NotesDocument.replaceItemValue(string, Date) null
How can I fix this?

The following works:
docContractor.replaceItemValue("ContractorStartDateTime", session.createDateTime("Today"));
You can find more examples in the Notes and Domino App Dev wiki: http://www-10.lotus.com/ldd/ddwiki.nsf/dx/NotesDateTime_sample_JavaScript_code_for_XPages

Did you try to use a NotesDateTime object instead?
Or use toString ()

Related

Shopware: Can not create variantes "(intermediate value).map is not a function"

Variant creation stucked. Console shows:
Uncaught (in promise) TypeError: (intermediate value).map is not a function
Degging deeper with the debugger variantRestrictions is broken in some way.
In the database product.variant_restrictions is an empty JSON array []. If I change it to NULL it worked again.
You can fix it like this:
UPDATE product SET variant_restrictions = NULL WHERE variant_restrictions = '[]';

angular: updateRenderer throws Cannot read property 'name' of undefined for string variable

I have a really strange problem with displaying a string variable. The error I'm getting is this:
ERROR TypeError: Cannot read property 'name' of undefined
at checkBindingNoChanges (core.js:9912)
at checkNoChangesNodeInline (core.js:13961)
at checkNoChangesNode (core.js:13935)
at debugCheckNoChangesNode (core.js:14764)
at debugCheckRenderNodeFn (core.js:14704)
at Object.eval [as updateRenderer] (MonitoringCriteriaComponent.html:93)
at Object.debugUpdateRenderer [as updateRenderer] (core.js:14686)
at checkNoChangesView (core.js:13775)
at callViewAction (core.js:14126)
at execEmbeddedViewsAction (core.js:14104)
This is thrown while trying to display a string type variable like this:
<span>{{daysCounter}}</span>
The variable is declared and changed this way:
daysCounter = '';
public countTotalNumberOfDays() {
this.daysCounter = '' + DateUtils.calculateNumberOfDays(this.dateFrom.datePickerTime.toDate(), this.dateTo.datePickerTime.toDate());
console.log('daysCounter', this.daysCounter);
}
The error is thrown after calculation is being made, as it's properly logged in the console log, however when it is being displayed in the html template, the above error is logged. Value of this variable is not accessed anywhere else. This is within one component, other variables are visible in the template.
I don't know what else might be relevant to this problem. I'm quite stumped...
I kept digging and found out that the reason for the error was a way function used to set its value was called. It was called in a (changeListener) in another component higher up, and while it was reported in console log correctly the error was thrown because the higher component, I'm guessing, did not have access to that variable. Logging in this case was very confusing.
The solution was moving the function changing the value of the var from the function used in changeListener to another spot, used only in that component.

Why am I getting a ConfigException 'Expected a comma separated list' error when creating a KafkaConsumer

I am trying to create a KafkaConsumer with the following Groovy code:
Properties props = new Properties()
props.put('bootstrap.servers', "$SERVER_ADDRESS:$port")
props.put('key.deserializer', StringDeserializer.name,)
props.put('value.deserializer', StringDeserializer.name)
return new KafkaConsumer<String, String>(props)
When I execute it, I am getting the following error:
org.apache.kafka.common.config.ConfigException: Invalid value
localhost:9092 for configuration bootstrap.servers: Expected a comma
separated list.
My code essentially matches the example creation of a Consumer from here
Why is my version not working?
In this case, the props object is expecting its values to be of type Object, and not only of type String. Therefore, when "$SERVER_ADDRESS:$port" is added as a property, it isn't coerced into a String and is stored as a GStringImpl.
The type checking done before creating a KafkaConsumer knows how to handle a String property value but not a GStringImpl and throws an error.
Changing the line to this works:
props.put('bootstrap.servers', "$SERVER_ADDRESS:$port".toString())
In version 0.10.0 using the KafkaConsumer or KafkaProducer, it expects an array of Strings. You are passing a String.

How to fetch rows based on CRM modifiedon column

I need to pull all rows from an entity which were modified recently. I am using the following statement which gives me an error
from e in myEntity
where e.ModifiedOn.HasValue
select e.cust_name
The error states
Invalid 'where' condition. An entity member is invoking an invalid property or method.
Message Invalid 'where' condition. An entity member is invoking an invalid property or method.
Try with:
from e in myEntity
where e.ModifiedOn != null
select e.cust_name
Using Lambda Expressions:
var getModified = myEntity.where(w=>w.ModifiedOn!=null).select(s=>s.cust_name);

Repeat control error in xpage

JavaScript code
1: db=database;
2: theView=db.getView(compositeData.PDviewname);
Error while executing JavaScript computed expression
Script interpreter error, line=2, col=12: [TypeError] Exception occurred calling method NotesDatabase.getView(null) null
You don't catch null values. One possible way:
var viewName = compositeDate.PDViewName == null ? 'someDefaultName' | compositeDate.PDViewName;
var theView = database.getView(viewName);
Of course you could also stop the code if viewName is null. You shouldn't use sessionScope here -> your code will break if a user has the unheard idea of opening 2 browser tabs in your application.

Resources