Developer Discussions

Discuss topics with other Hexagon Geospatial Power Portfolio developers and experts to get the most out of our products.
Showing results for 
Search instead for 
Do you mean 
New Contributor
Posts: 3
Registered: ‎01-28-2016
Accepted Solution

GMSC Offline Mode - Combobox value via Javascript




Pardon for my questions as I'm new to GMSC and inherit the code from previous dev.

In SmartClient 2014, by using javascript, I'm able to retrieve values from fields in a form using form.getItemById('ATTRIBUTE').getValue();
But after upgrading to SmartClient 2015, when retrieving value using the same method, the values return are empty. Therefore I'm unable to set a combobox selected value. The questions are, is it a bug? or is there any other method for setting the existing value in offline mode?



Here's the field that I want to fill and set up:



<OfflineForm name="ED_DEMAND_POINT_OFFLINE" table="ED_DEMAND_POINT" label="Offline Form: Demand Point" idfield="ID" 
		<FormGeometry layer="323" name="LOCATION">
		<FormTab name="ED_DEMAND_POINT_OFFLINE_Tab" label="Attributes:">
			<FormGroup name="ED_DEMAND_POINT_OFFLINE_Group" label="Demand Point [Offline]">
				<FormField name="ID" label="ID:" type="textfield" datatype="number" required="false" visible="hidden" maxlength="22"/>
				<FormField name="STATUS" label="Status:" type="combobox" datatype="string" required="true" editable="true" defaultvalue="Inactive" maxlength="16"/>
		<FormAction name="SAVEANDEDITGEOMETRY" label="Save Geometry" action="SCRIPT[IG.captureOfflineGeometry()]" />
		<FormAction name="SAVE" label="Save Attribute" action="save" />
		<FormAction name="DELETE" label="Delete" action="delete" />
		<FormAction name="CLOSE" label="Close" action="SCRIPT[IG.closeWebBrowser()]"  />



And here's the javascript that I used:



var status1 = new Array();
status1 = [
	{id: 'Abandoned', name: 'Abandoned'},
	{id: 'Assumed', name: 'Assumed'},
	{id: 'Existing', name: 'Existing'},
	{id: 'Inactive', name: 'Inactive'},
	{id: 'Proposed', name: 'Proposed'},
	{id: 'Proposed Abandon', name: 'Proposed Abandon'},
	{id: 'Proposed Remove', name: 'Proposed Remove'},
	{id: 'Proposed Replace', name: 'Proposed Replace'},
	{id: 'Removed', name: 'Removed'},
	{id: 'Temporary', name: 'Temporary'}

	var lovstatus = form.getItemById('STATUS');
	var tempstatus = lovstatus.getValue();
	//alert('XXXXX>' + form.getItemById('STATUS').getValue() + '<XXXXX');



 Any ideas?








Frequent Contributor
Posts: 78
Registered: ‎10-12-2015

Re: GMSC Offline Mode - Combobox value via Javascript

[ Edited ]



Try this implementation of your code:

Replace it with the IG.vent.on... part of your javascript. {
	if(IG.getItemById('STATUS') != undefined) {	//This is to ensure that the code is only executed on forms that have the STATUS item
		var lovstatus = IG.getItemById('STATUS');
		var tempstatus = lovstatus.getValue();
		//alert('XXXXX>' + IG.getItemById('STATUS').getValue() + '<XXXXX');

Hope this helps,


New Contributor
Posts: 3
Registered: ‎01-28-2016

Re: GMSC Offline Mode - Combobox value via Javascript

Hi RaduConst,


Thanks for replying..


Even though its a bit late for me to reply back..


But your solution didn't really work for me..


It passed through the if statement.. But the *.getValue() still return an empty string..



Anyway.. We manage to find a workaround for it..


Instead of using the getValue()..


I'm using IG.form.getItemById('COMBOBOX_FIELD_NAME').fieldConfig.value instead..


This will return some result for me..


Therefore, here's my script look like:


IG.vent.on('form:ready', function(form){
    var lov_status = IG.form.getItemById('STATUS');
    var temp_status = IG.form.getItemById('STATUS').fieldConfig.value;
    lov_status.fill(status1, temp_status);




Thank you..



With regards,