JSCalculation returning media not working

Hi all.

I have added a calculation to an in memory datasource created through a query that should return a media. That calculation works fine when I use it directly from the table but not when adding it to an in memory datasource. Maybe I’m missing an stupid thing, but I can’t see it !!!

This is the code in the calculation:

/**
 * @properties={type:-4,typeid:36,uuid:"5D89F8E6-7F40-4114-A0AC-07117824BD91"}
 */
function instruction_source() {
	//application.output('instruction_source calculation running');
	var _media = "media:///privatelogo.png";
	if (customer_type == 0 || customer_type == null) {
		_media = "media:///Qualitas_90_90.png";
	} else if (customer_type == 1) {
		_media = "media:///d2icon.png";
	}
	return _media
}

This is the code where I read the calculation and add it to my new datasource:

	/**
	 * JASM on 29 Jan 2016
	 *
	 * Get the calculation to show the source icon from the specialists_appointments table
	 * Then add it as a new calculation to the claimantsDataSource data source we've just created
	 */
	var _appsDataSourceNode = solutionModel.getDataSourceNode('db:/clinics_manager/specialists_appointments');
	var _instructionSourceCalculation = _appsDataSourceNode.getCalculation('instruction_source');
	var _jsDataSourceNode = solutionModel.getDataSourceNode(claimantsDataSource);
	var _jsCalculation = _jsDataSourceNode.getCalculation('instruction_source');
	if (_jsCalculation == null) {
		_jsDataSourceNode.newCalculation(_instructionSourceCalculation.code, _instructionSourceCalculation.variableType);
	}

And this is the code when I add the field to the form:

	_lbl = _jsForm.newLabel('S', 285, 35, 20, 20);
	_lbl.labelFor = 'instruction_source';
	_lbl.name = 'instruction_sourcen_label';
	_lbl.styleClass = 'gridheader';
	_fld = _jsForm.newField('instruction_source', JSField.IMAGE_MEDIA, 285, 55, 20, 20);
	_fld.name = 'instruction_source';
	_fld.editable = false;
	_fld.styleClass = 'gridcell';

Any idea?

Thanks in advance

i have to check if that is really supported, adding calculations to a in mem datasource
Because that is not something you can really do, a runtime created datasource is a bit different then an actual database datasource defined in the developer.

Hi Johan. It’s doable, I finally got it but not returning a media. I’m returning an html string to show the image. I will post the solution tomorrow morning.

Cheers