Field not being updated after calculation and setFieldConten

Posted by ionacaerex on 03-Jul-2016 06:07

<script>

I have included a calculation to dervie a field value - all works well in edit mode with dynamic update (as event is set too). Problem is field does not seem to be updated on database. When view is selected, field is set to zero? 

Would it be something to do with the field value rather than the field?

Any ideas. Many Thanks in advance...

Cose is as follows -------------------

function calc_interest()
{
var m = rbf_getFloat(rbf_getFieldValue("advanced_amount"));
var r = rbf_getFloat(rbf_getFieldValue("monthly_rate_"));
var t = rbf_getFloat(rbf_getFieldValue("term"));
var total_charge_for_credit = (t/12)*m*r/100;
rbf_setFieldContent("total_charge_for_credit",
rbf_formatCurrency(total_charge_for_credit, "£"));
}


</script>

All Replies

Posted by Mohammed Siraj on 03-Jul-2016 23:08

In form pages, to set a form field value you should be using:

rbf_setFieldValue. Next, on submitting form, the field value will be persisted against the relevant record.

rbf_setFieldContent is meant to be used in Record view pages for setting contents of derieved fields like Template & Formula.

Posted by ionacaerex on 06-Jul-2016 12:08

Hi Mohammed - thanks for your help

Apologies I am a busiines not technical user so syntax is difficult for me.

What is the exact syntax for SetFieldValue and how does it differ setfieldcontent.

Thanks

Code below....

<script>

  function calc_interest()

{

   var m = rbf_getFloat(rbf_getFieldValue("advanced_amount"));

   var r = rbf_getFloat(rbf_getFieldValue("monthly_rate_"));

   var t = rbf_getFloat(rbf_getFieldValue("term"));

   var total_charge_for_credit = (t/12)*m*r/100;

   var total_amount_repayable = total_charge_for_credit+m;

   var monthly_repayment = total_amount_repayable/t;

   var PerCost = total_amount_repayable/m;

     rbf_setFieldContent("total_charge_for_credit",

   rbf_formatCurrency(total_charge_for_credit, "£"));

   rbf_setFieldContent("total_amount_repayable",

   rbf_formatCurrency(total_amount_repayable, "£"));

   rbf_setFieldContent("monthly_repayment",

   rbf_formatCurrency(monthly_repayment, "£"));

   rbf_setFieldContent("PerCost",

   rbf_formatCurrency(PerCost, "£"));

   }

 </script>

Posted by Mohammed Siraj on 07-Jul-2016 04:44

To set a form field value on client-side:

rbf_setFieldValue("total_charge_for_credit", total_charge_for_credit);

On submitting form i.e. field value will be  updated in database.

In comparison rbs_setFieldContent should be used for setting html for a field. Say that you have a 'rating' field of type integer with values ranging from 1 - 5. In application page, you want to render this field as 'Star-shaped' icons depicting rating i.e. 4 icons for a rating 4. In such a scenario, you should leverage rbf_setFieldContent to render the appropriate HTML. This is mostly applicable for view pages (i.e. Record Details) and not form pages (i.e. New/Edit record).

For more details:

documentation.progress.com/.../index.html

documentation.progress.com/.../index.html

This thread is closed