SpEL in jsonRPC when using scripts initialization dataservices

Hi there,

Is there a way to use dynamic values ​​in JSON files to initialize data when the application starts?

My idea is:

[
	{
		"jsonrpc": "2.0",
		"method": "ADD_DOCUMENT",
		"id": "addDocumentOperation",
		"params": {
			"documentModelName": "Broker",
			"document": {
				"Broker": {
					"BrokerData": {
						"ActiveFlag" : true,
						"Name" : "Testbroker 1"
					},
					"MetaData": {
						"CreatedBy": "mgmadmin",
						"CreatedAt": "#{T(java.time.LocalDate).now().plusMonths(1)}"
					}
				}
			},
			"locale": "en"
		}
	}
]

But it seems to dataservices component didn’t support it.

Versions:

a12BaseVersion=27.1.0
a12UaaVersion=7.5.1
a12KernelVersion=28.5.1
a12FormEngineVersion=36.7.0
a12DataServicesVersion=36.3.7

Please help me confirm it! Thank you!

Hi @nhat-round-cloud,
Unfortunately, at the configuration level, Dataservices does not yet support this feature.

Because of security reasons, no such feature is even planned. Currently, there is just a restricted possibility to reference previous operations results in the RPC SpEL.

Hi there,

is there any chance this might get supported in the future?

I understand that RPC calls are used to read/write JSON files in general and therefore security reasons apply. But the use case the above question came from is: importing test data on application start up.

We have quite extensive test data JSONs because we have quite complex use cases and cannot always create test data manually. The test data JSONs contain a lot of dates and these dates expire over time and then the test data is corrupt and we cannot use them anymore, because a lot of validations fire. We then need to adapt these test data JSONs manually and set the dates farther in the future. And we need to do that quite often, because we cannot set the dates too far in the future, because that would also trigger validations.

TL;DR ?
Could you think about allowing SpEL in jsonRPC calls if a “test-data flag” is true or something?
Or provide any other solution to add dynamic data (especially dates) to JSON test data files?

Thank you and
Kind regars,
Bianca

Hi @bianca-firm-knoll,

if you need such a feature, create a feature request in Jira. Please describe which fields should support SpEL and what data should be available there. Then we can consider extending the current dataset. But unlimited SpEL is very dangerous and I don’t expect it will be allowed.