rbf_updateFieldDef not updating field definition

Posted by Meryk on 09-Apr-2015 06:38

Hello,

I am using the function rbf_updateFieldDef on an Integer field, for which I want to set the "Default Value".

Here is the code I am using :

function callback1(xmlUpdated){

xmlUpdated = $.parseXML(someXml);
$xml = $(xmlUpdated);
$props = $xml.find("Props");
$props.append('<defValue>250<//defValue>');

// alert( (new XMLSerializer()).serializeToString(xmlUpdated) );  ==> (Please see the Screen Shot of the alert below)                 

}
rbf_updateFieldDef(xmlFieldDef, callback1);

When I alert the XML definition of the Field, the node "<defVAlue>250</defValue>" is added to Props as you can see. But no default value is set in the field.

Am I doing something wrong here ? Is the order of the appending important?

Also, I was expecting to see the field "Default Value" in the definition of my Integer Field, filled in, but it is not. (Ref the screenshot below).

Any Ideas please?

Thank you guys.

Meryem

Posted by Godfrey Sorita on 10-Apr-2015 16:32

Can you please try using the code below? This is the same code you provided with few modifications. 

<script src='../js/metadata.js' type='text/javascript' charset='utf-8'></script>
 
<script>
$(document).ready(function(){
	function callback1(xmlFieldDef) {
		alert(xmlFieldDef);
		xmlUpdated = $.parseXML(xmlFieldDef);
		$xml = $(xmlUpdated);
		$props =  $xml.find("Props");
		$props.append('<defValue>250</defValue>')
		xmlFieldDef = (new XMLSerializer()).serializeToString(xmlUpdated);
		rbf_updateFieldDef(xmlFieldDef, callback2);
	}

	function callback2(data) {
		alert(data); 
	}
	
	rbf_getFieldDef('Parent', 'int1', callback1);
});
</script>


This code worked also worked in my environment. The property is being updated in the edit field page. 

All Replies

Posted by pvorobie on 09-Apr-2015 12:00

Please try using rbf_getFieldDef first to extract field's XML.

Posted by Godfrey Sorita on 09-Apr-2015 16:51

What version of Rollbase are you using? The order is certainly not an issue because it worked in my environment using the code below:

<script src='../js/metadata.js' type='text/javascript' charset='utf-8'></script>
<script>
var xmlString = '<DataFieldDef id="10950" origid="10950" objDefName="Parent" columnname="INTG2" fieldName="int1" dataName="FieldInt" uiClass="IntInput" isRequired="false" isReadonly="false" istextindexable="false" issystem="false" isauditable="false" maxlength="0"><DisplayLabel>int1</DisplayLabel><Props><isUnique>false</isUnique><grouping>false</grouping><inlineEdit>true</inlineEdit><defValue>96</defValue></Props></DataFieldDef>';

rbf_updateFieldDef(xmlString, updateFieldDef, errorCallback);

function updateFieldDef(data){
  alert(data)
  rbf_getFieldDef("Parent", "int1", getFieldDef, errorCallback);
}

function getFieldDef(data){
  alert(data);
}

function errorCallback(data){
  alert(data);
}
</script>


Posted by Meryk on 10-Apr-2015 04:46

Hi Godfrey,

I am using version 3.2. I am already using the function rbf_getFieldDef to get the XML String I am parsing and updating.

Here is the entire script :

<script src='../js/metadata.js' type='text/javascript' charset='utf-8'></script>

<script>

$(document).ready(function(){

  function callback(xmlFieldDef){

    alert(xmlFieldDef);

    function callback1(xmlUpdated){

       xmlUpdated = $.parseXML(xmlFieldDef);

       $xml = $(xmlUpdated);

       $props =  $xml.find("Props");

       $props.append('<defValue>250</defValue>');

       alert( (new XMLSerializer()).serializeToString(xmlUpdated) );

    }

    rbf_updateFieldDef(xmlFieldDef, callback1);

   }

  rbf_getFieldDef('webPage', 'contentWidth', callback);

});

 </script>

How is it working in your environment? Is it updating something in the definition of your object? Because the Xml is updated but not the definition.

Thanks

Mery

Posted by Godfrey Sorita on 10-Apr-2015 16:32

Can you please try using the code below? This is the same code you provided with few modifications. 

<script src='../js/metadata.js' type='text/javascript' charset='utf-8'></script>
 
<script>
$(document).ready(function(){
	function callback1(xmlFieldDef) {
		alert(xmlFieldDef);
		xmlUpdated = $.parseXML(xmlFieldDef);
		$xml = $(xmlUpdated);
		$props =  $xml.find("Props");
		$props.append('<defValue>250</defValue>')
		xmlFieldDef = (new XMLSerializer()).serializeToString(xmlUpdated);
		rbf_updateFieldDef(xmlFieldDef, callback2);
	}

	function callback2(data) {
		alert(data); 
	}
	
	rbf_getFieldDef('Parent', 'int1', callback1);
});
</script>


This code worked also worked in my environment. The property is being updated in the edit field page. 

Posted by Meryk on 13-Apr-2015 03:22

Thank you Godfrey. It is working now with your code! :)

Mery

This thread is closed